Closed bricebou closed 6 years ago
I don't really see a reason why matching the category by title is necessary, it's a rather error-prone approach (as you're experiencing right now). How about adding Category: my_category_1
to your root/supcategory/category/index.md
(see https://github.com/picocms/Pico/issues/438#issue-335085179) and using the same Category
meta header in your category page (root/supcategory/category/page.md
) to match the page? You just have to replace the cate
variable (meta.title
right now) by meta["Category"]
.
That's not the issue...
The twig code with what you mentionned commented:
<h1>{{ meta.title }}</h1>
{# {% set cate = meta.title|trim %} #}
<ul class="wlist vtl categ">
{% for page in pages %}
{# {% if page.meta["Category"]|trim is sameas(cate) and page.meta["template"]|trim != 'category' %} #}
<li>
<a href="{{ page.url }}">
<time class="vtl_date meta" datetime="{{ page.date }}" ><span>{{ page.date|date("d/m/Y", "Europe/Paris")}}</span></time>
<div class="vtl_point"><i class="fa"></i></div>
<div class="vtl_label">
{{ page.title }}
</div>
</a>
</li>
{# {% endif %} #}
{% endfor %}
</ul>
And the HTML output for two articles which title starts with [Avancé]
:
<li>
<a href="http://dev.localhost/tutos/LaTeX">
<time class="vtl_date meta" datetime="" ><span>26/06/2018</span></time>
<div class="vtl_point"><i class="fa"></i></div>
<div class="vtl_label">
LaTeX
</div>
</a>
</li>
<li>
<a href="http://dev.localhost/tutos/GCweb/GCweb_nom_champs">
<time class="vtl_date meta" datetime="" ><span>26/06/2018</span></time>
<div class="vtl_point"><i class="fa"></i></div>
<div class="vtl_label">
</div>
</a>
</li>
<li>
<a href="http://dev.localhost/tutos/GCweb/GCweb_champs_perso">
<time class="vtl_date meta" datetime="" ><span>26/06/2018</span></time>
<div class="vtl_point"><i class="fa"></i></div>
<div class="vtl_label">
</div>
</a>
</li>
<li>
<a href="http://dev.localhost/tutos/GCweb">
<time class="vtl_date meta" datetime="" ><span>26/06/2018</span></time>
<div class="vtl_point"><i class="fa"></i></div>
<div class="vtl_label">
GCweb
</div>
</a>
</li>
As you can see, the vtl_label
div appears empty for two entries. Here are the meta headers of these two files:
/*
Title: [Avancé] GCweb : Modier l'intitulé des champs
Description: Modifier l'intitulé des champs affichés par GCweb
Author: Brice Boucard
Date: 2011/08/04
License: Creative Commons Attribution-ShareAlike 4.0 International License
Tags: GCweb,web,GCstar,bibliothèque,php,Sublime Text
Category: GCweb
Template: index
*/
/*
Title: [Avancé] GCweb : Ajout de champs personnalisés
Description: Ajouter des champs personnalisés dans GCweb
Author: Brice Boucard
Date: 2011/08/05
License: Creative Commons Attribution-ShareAlike 4.0 International License
Tags: GCweb,web,GCstar,bibliothèque,php
Category: GCweb
Template: index
*/
I've tried to switch to the default theme and to access the page where I have a meta title with brackets.
Title: [Avancé] GCweb : Modier l'intitulé des champs
And here is the PHP error I get:
[Wed Jun 27 22:15:57.843942 2018] [php7:error] [pid 21610] [client ::1:40088] PHP Fatal error: Uncaught Symfony\\Component\\Yaml\\Exception\\ParseException: Unexpected characters near " GCweb : Modier l'intitul\xc3\xa9 des champs" at line 7 (near "Title: [Avanc\xc3\xa9] GCweb : Modier l'intitul\xc3\xa9 des champs"). in /home/bbrice/webdev/www-dev/vendor/symfony/yaml/Inline.php:76\nStack trace:\n#0 /home/bbrice/webdev/www-dev/vendor/symfony/yaml/Parser.php(536): Symfony\\Component\\Yaml\\Inline::parse('[Avanc\\xC3\\xA9] GCweb...', false, false, false, Array)\n#1 /home/bbrice/webdev/www-dev/vendor/symfony/yaml/Parser.php(258): Symfony\\Component\\Yaml\\Parser->parseValue('[Avanc\\xC3\\xA9] GCweb...', false, false, false, 'mapping')\n#2 /home/bbrice/webdev/www-dev/vendor/symfony/yaml/Parser.php(78): Symfony\\Component\\Yaml\\Parser->doParse('Title: [Avanc\\xC3\\xA9...', false, false, false)\n#3 /home/bbrice/webdev/www-dev/vendor/picocms/pico/lib/Pico.php(1335): Symfony\\Component\\Yaml\\Parser->parse('Title: [Avanc\\xC3\\xA9...')\n#4 /home/bbrice/webdev/www-dev/vendor/picocms/pico/lib/Pico.php(442): Pico->parseFileMeta('/*\\nTitle: [Avan...', Array)\n#5 in /home/bbrice/webdev/www-dev/vendor/symfony/yaml/Inline.php on line 76
I've tried without any success with double quotes, single quotes...
Title: "[Avancé] GCweb : Ajout de champs personnalisés"
Works fine for me with double quotes:
Hum... inexplicable, but today, after booting my computer, it works just with double quotes...
Sorry for the noise...
Hi,
Working on the upgrade to Pico CMS v. 2, I've just met an issue that took me some time to understand.
I have two articles with a meta title beginning with a word between brackets:
and these articles didn't show inside my category page, neither in the tag page.
Removing the brackets, they appear. I've tried to escape them (
\[Avancé\]
), to replace them with the hex code ([
and]
) but nothing. I've tried to disable the Parsedown Extra parser but without effect. It worked with my actual production Pico (but I think it's a 0.9 version).Any idea ?
Thanks !