Closed bricebou closed 6 years ago
There were some breaking changes in Pico 2.0 towards theming. Please refer to the current WIP version of Pico's upgrade docs at http://phrozenbyte.github.io/Pico/in-depth/upgrade-pico-20/ to see what has changed and how to make your theme compatible with Pico 2.0.
Furthermore it seems that you're using the category
meta wrong? In category.html
there's L14 and L17, so you're comparing a page title (meta.title
) with a boolean (category: true
in your YAML Front Matter)?
It's because it's the previous version of the code but I've changed my yaml content header because thought the "category" meta was from the core based on https://github.com/picocms/Pico/issues/414... :-/
Initially, here what a supcategory index.md:
/ Title: Mon parcours Author: Brice Boucard License: Creative Commons Attribution-ShareAlike 4.0 International License Template: supcategory /
And here is the category meta index.md:
/ Title: Maîtrise Sciences du langage Author: Brice Boucard License: Creative Commons Attribution-ShareAlike 4.0 International License Template: category Category: Mon parcours /
My theme on v1 renders that : http://momh.fr/parcours/M1 But, with v2, it doesn't show anything but the title.
So, I'm trying to use in my category.twig
template the current_page.tree_node.children
mentioned in https://github.com/picocms/Pico/issues/414 but it seems it's "empty"...
{% for item in current_page.tree_node.children %} {{ item.category }} - {{ item.title }} <br> {{ meta["Category"] }} <br> {% endfor %}
You are not required to use Pico's new page tree system if you had a working solution before. Your old solution should work with Pico 2.0 without any changes necessary. #414 is a completely different approach, you can't mix this solution with your solution.
If you really want to use Pico's page tree system, refer to the current WIP version of Pico's page tree documentation. The tree_node.children
array is not a list of pages, but a list of tree nodes. You're rather looking for item.page.meta.category
- but note that item.page
doesn't necessarily exist (see the docs).
The thing is: what worked doesn't work anymore...
I was using the AdvancedMeta plugin and declared some meta this way:
$config['custom_meta_values'] = array(
//page category
'category' => 'Category',
//page status
'license' => 'License',
'thumbnail' => 'Thumbnail'
);
Unfortunately I can't help you if you just give me "it doesn't work anymore" :wink:
The plugin with this config shouldn't make any difference here.
Of course :-)
It was more kind of a question: do I have to keep with the version 2 of Pico the AdvancedMeta plugin, or is there a way to let it aside ? I thought it was no longer necessary... and I thought you didn't have to declare custom meta...
But, of course, I wasn't clear --"
Thanks :-)))
There were some changes regarding the handling of meta headers that weren't registered by a plugin. See the 5th paragraph of http://phrozenbyte.github.io/Pico/in-depth/upgrade-pico-20/#amazing-new-features-for-theme-developers. You should access the meta value "Category" using meta["Category"]
(note the uppercase C
, i.e. case matters now).
The AdvancedMeta
plugin never really was necessary. Its existance is a sign that Pico's handling of meta headers was a bit confusing in the past. That's one of the the reason why we no longer do unexpected things and simply pass unregistered meta headers through without change.
Theme developers don't have to register meta values. You just have to make sure that you use the exact same keys, i.e. if your theme uses {{ meta["category"] }}
, use category: My category
in your YAML Front Matter. If your theme rather uses {{ meta["Category"] }}
, use Category: My category
in your YAML Front Matter (note the uppercase C
).
Ok...
But in my category.twig
template, I have this:
{% for page in pages %}
{% if page.meta["Category"] is sameas(cate) and page.template != '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 %}
Of course, it doesn't produce any result.
If I try to replace page.category
with page.meta["Category"]
, it doesn't produce anything...
Any idea ? Thanks :-)
Try debugging which values the variables page.meta["Category"]
, page.meta["category"]
and cate
actually hold. Enalbe Twig's debug mode by adding twig_config: { debug: true }
to your config/config.yml
and add {{ dump(page.meta["Category"], page.meta["category"], cate) }}
(after for
, before if
) to your Twig template.
Thanks !
It seems that the trim
Twig filter is a part of the solution: using {% set cate = meta.title|trim %}
and then if page.meta["category"]|trim is sameas(cate)
renders some results.
But:
Category: test
is accessible with page.meta["category"]
but isn't with page.meta["Category"]
page.template
but needs to be called with `page.meta["template"]. Here again, the initial capital is left aside.Thanks again !
What does {{ dump(current_page, version) }}
output? (outside the for
loop)
Here it is:
array(11) { ["id"]=> string(17) "parcours/M1/index" ["url"]=> string(38) "http://dev.localhost/parcours/M1/index" ["title"]=> &string(29) "Maîtrise Sciences du langage" ["description"]=> &string(0) "" ["author"]=> &string(13) "Brice Boucard" ["time"]=> &string(0) "" ["date"]=> &string(0) "" ["date_formatted"]=> &string(0) "" ["raw_content"]=> &string(181) "/* Title: Maîtrise Sciences du langage Author: Brice Boucard License: Creative Commons Attribution-ShareAlike 4.0 International License Template: category Category: Mon parcours */" ["meta"]=> &array(10) { ["title"]=> &string(29) "Maîtrise Sciences du langage" ["author"]=> &string(13) "Brice Boucard" ["license"]=> string(65) "Creative Commons Attribution-ShareAlike 4.0 International License" ["template"]=> string(8) "category" ["category"]=> string(12) "Mon parcours" ["description"]=> &string(0) "" ["date"]=> &string(0) "" ["robots"]=> string(0) "" ["date_formatted"]=> &string(0) "" ["time"]=> &string(0) "" } ["content"]=> &string(0) "" } NULL
It seems that the version doesn't show anything, isn't it ?
Yes, that's because this is no Pico 2.0 installation :wink: You said that you were trying to "move from version 1 to the latest Pico's development", but you're still using Pico 1.0. You can download the latest beta of Pico 2.0 here: https://github.com/picocms/Pico/releases
Hum... I don't understand...
I've used git clone git@github.com:picocms/Pico.git
and run composer install
... what have I done wrong ?
You've cloned the master
branch, that is always the current stable release branch. Until Pico 2.0 is released, Pico 2.0 is found in the pico-1.1
branch (development startet as Pico 1.1 and was later renamed to Pico 2.0). This is explained in Pico's CONTRIBUTING.md
. Anyway, you shouldn't use Git branches for a productive website anyway, but rather the latest release.
You can download the latest beta of Pico 2.0 here: https://github.com/picocms/Pico/releases. Pico's pre-bundled release is basically just a Composer installation packed in a ZIP archive. There's virtually no difference between a pre-bundled release and a Composer installation, both use picocms/pico-composer
as a basis (however, you can't use picocms/pico-composer
directly without changing Composer's minimum-stability
until Pico 2.0 is released, thus I'd recommend to simply use the pre-bundled release, composer
works with pre-bundled releases, too).
Hum... --' Sorry...
So, I'm now running the latest beta of version 2. But I still see a problem with no-case sensitive meta.
in my twig category template:
{{ page.template }} -- {{ page.meta["template"]}} -- {{ page.meta["Template"] }} <br>
{{page.category }} -- {{ page.meta["category"]}} -- {{ page.meta["Category"] }}
And here the result:
-- index --
-- Master professionnel Édition -- Master professionnel Édition
And here is the meta header of my content file:
/*
Title: Histoire de l'édition : la censure en France...
Description: Dossier d'histoire de l'édition : la censure en France... de la censure « officielle » à la « censure invisible »
Author: Brice Boucard
Date: 2009/07/02
License: Creative Commons Attribution-ShareAlike 4.0 International License
Tags: études,édition
Category: Master professionnel Édition
Template: index
*/
I can't give you the result of the dump
command you gave earlier because of a memory limit (small and slow computer and memory limit fixed in php.ini fixed at 256 MB)...
That's how it is supposed to work.
Template
is a registered meta header that intentionally changes the meta header's key. That's the reason why it is only accessible using {{ page.meta["template"] }}
. Just refer to Pico's onMetaHeaders
event.
The reason why you can access the unregistered meta header Category
using both {{ page.meta["category"] }}
and {{ page.meta["Category"] }}
is explained in http://phrozenbyte.github.io/Pico/in-depth/upgrade-pico-20/: {{ page.meta["Category"] }}
is the correct one for Pico 2.0, but PicoDeprecated
preserves BC by making the meta value also accessible using {{ page.meta["category"] }}
. You can disable PicoDeprecated
by adding PicoDeprecated.enabled: false
to your config/config.yml
.
I have this parameter set on default in my config.yml
:
DummyPlugin.enabled: false
Sorry ! too fast reading
Made it working ! ... --' Thanks again :)
Hi,
It's been a while but I'm trying to move from version 1 to the latest Pico's development.
But I can't make my theme working :-(
I have a three levels folder system:
I've read https://github.com/picocms/Pico/issues/412 and https://github.com/picocms/Pico/issues/414 but I can't make anything work :-(
My old theme is here and https://github.com/bricebou/pico_momh
Here are some questions:
Thanks in advance !