Closed iagovar closed 6 years ago
This is a task predestined for the page tree shipped with Pico 2.0. You can download the latest beta from https://github.com/picocms/Pico/releases (also see #401). Don't worry about Pico 2.0 being in beta, it's actually ready-to-release, we just haven't finished the docs/website updates yet.
First create a index.md
in all folders representing categories and add a YAML header (e.g. content/my_category/index.md
):
---
title: My category
category: true
template: category
---
Listing categories (your index.twig
):
<ul>
{% for category in pages["index"].tree_node.children %}
{% if category.page and category.page.meta.category %}
<li><a href="{{ category.page.url }}">{{ category.page.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
Listing pages in a category (your category.twig
):
{% if meta.category and current_page.tree_node.children %}
{% for child in current_page.tree_node.children %}
{% if child.page and not child.page.hidden %}
<div>
<h3><a href="{{ child.page.url }}">{{ child.page.title }}</a></h3>
<p>{{ child.page.description }}</p>
</div>
{% endif %}
{% endfor %}
{% endif %}
#edit: Splitting templates.
Thank you, I'll download the 2.0 version and tell you if it worked.
It worked! Now I have another question. I want to put a PHP include inside a .md file. but it seems to output in plain text. Is there any way to scape the markdown interpreter for a few lines or any other way to do something similar?
This is not possible (on purpose). Use a Twig template instead (e.g. add Template: special_page
to the YAML header of content/special_page.md
and create a themes/my_theme/special_page.twig
). If Twig really isn't sufficient, you'll have to create a Pico plugin instead (refer to the plugins section in the user docs, the (unfinished, help is highly appreciated) dev docs at http://picocms.org/development/ and Pico's DummyPlugin
).
Well, if someone has the same problem, I'm doing it throug jquery:
`
` ``@PhrozenByte what if I change the documents format from .md to .html in the config file? Will that allow me to use php include?
No
:(
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:
Hi all. I'm looking for a way to show in the index page the folders inside /content.
Basically I'm trying to recreate a SILO structure in my site, so the index page shows the categories of the site and a list of links where template: page. When the user clicks that categories another page shows listing all the documents inside such category.
I've looked in the picocms docs but I didn't find anything suitable, and reading twig documentation I'm a bit lost to be honest.