picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.83k stars 617 forks source link

content filter in version 2 ? #444

Closed bricebou closed 6 years ago

bricebou commented 6 years ago

Hi,

I'm trying to use the content filter in my version 2 theme (based on https://github.com/picocms/Pico/issues/376) but it renders nothing.

I've looked in Pico's core https://github.com/picocms/Pico/blob/af237c1d672ca254a07d0359bfd9c3a5e0723f4c/lib/Pico.php#L1956 but without result...

{{ item.raw_content }} renders all the .md files, as wanted, but adding the filter produce nothing.

{% for item in pages %}{{ item.raw_content|content }}{% endfor %}

I'm running version 2.0.0-beta.3

What am I doing wrong ? :-/

Thanks in advance !

PhrozenByte commented 6 years ago

Please refer to Pico's user docs at http://picocms.org/docs/. It's {{ "sub/page"|content }}.

bricebou commented 6 years ago

Hum... I tried this one before posting... but without any success (the page.id return the correct path):

{% for page in pages %}{{ page.id }} // {{ page.id|content }}{% endfor %}

I'm doing a lot of things wrong...

bricebou commented 6 years ago

Hum...

I've tried to get back to the basics: using the default theme and the content-sample. It wasn't working because of file permissions... But then, moving back to my content and my theme, another issue: it seems that the PicoTags plugin (https://github.com/bricebou/PicoTags/blob/master/PicoTags.php) I've tried to rewrite causes the pages array issue :-/

It's strange, cause I have the right {{ pages|length }}and all the{{ page.id }}. It's only the{{ page.id|content }}` that doesn't display anything.

bricebou commented 6 years ago

After some more investigations, it was due to the fact that PicoTags rewrited the pages array: https://github.com/bricebou/PicoTags/blob/823b31b9f264866f449d3de629e779bf52b15aa4/PicoTags.php#L190-L191

Declaring a new array and a new Twig variable does the trick. I might ask later for a code review, once I've tried more this plugin and pushed to GitHub the changes.

Sorry, again...