nextcloud / cms_pico

🗃 Integrate Pico CMS and let your users manage their own websites
https://apps.nextcloud.com/apps/cms_pico
GNU Affero General Public License v3.0
134 stars 42 forks source link

Hidden: true not working #216

Closed johnwry closed 1 year ago

johnwry commented 1 year ago

There’s an issue where even though I’m putting Hidden: true within the YAML section those files are still appearing as links.

mayamcdougall commented 1 year ago

Are you using a custom theme?

Ignoring pages marked hidden is up to the Theme in Pico. So, especially if you've downloaded an older one, you might find it not implemented. A lot of the older themes were written before this was a standard.

Fortunately, it's not too difficult to add this functionality. In the Theme's index.twig, find the navigation code and just add an if statement inside the loop:

{% for page in pages() %}
  {% if not page.hidden %}
   <!-- Navigation Link -->
  {% endif %}
{% endfor %}

Hopefully this helps. Let me know if you have any other questions. 😁

johnwry commented 1 year ago

I am using a custom theme. To be fair, just about all the themes are either no longer maintained or the last update was like 7 years ago.

I tried to insert the code you suggested but the links are still showing up in the navigation even though Hidden: true is set.

mayamcdougall commented 1 year ago

Sorry for the delay, I haven't had a lot of time lately.

So, I'm not sure what the issue is. Judging by the code snippet you initially provided, it looks like you're basing your theme on Jon Beckett's Theme. I've made the same changes myself, and even tried using the code snippet you provided (they're identical anyway, since it's just changing page.date to page.hidden), and it works for me. I'm testing it in standard Pico though and not Pico for Nextcloud.


@PhrozenByte do you have any insight here? It's a pretty simple example, so I'm not sure where something would be going wrong.

From pico-jonbeckett, but using page.hidden instead of page.date:

{% for page in pages %}
{% if not page.hidden %}
<li class="{{ page.id == current_page.id ? 'active' }}"><a href="{{ page.url }}">{{ page.title }}</a></li>
{% endif %}
{% endfor %}

But yeah, most of our themes are ancient. They are often contributed once, then abandoned. They can still act as a good base for something new, or as reference (though, as time moves on this feels less true, since they often contain outdated code examples). At some point we'd like to highlight some recommended, "Ready-to-go" themes that are actively maintained, though at the moment that list would be quite short. 😒

If you're still curious about displaying only pages in a specific folder, check out the extended documentation on the pages() function.

It's a little rough of a read, but the basic premise is: Use pages(page-id), with page-id being the id of the page who's children you want (in your case, the directory you want to list). By default, this will only list one generation of children, but you can add a depth parameter to go deeper than that (eg pages(page-id, depth=1) would also list grandchildren). You can also pass depth=null to return ALL grandchildren.

PhrozenByte commented 1 year ago

@PhrozenByte do you have any insight here?

@johnwry Don't forget to reload your theme using the app's admin interface in Nextcloud after you've edited your Twig templates.

johnwry commented 1 year ago

@PhrozenByte so every change in a twig needs a reload for all users in the settings? How would I do this? Remove it and add it? Sent from my iPhoneOn 18 Oct 2022, at 12:09 PM, Daniel Rudolf @.***> wrote:

@PhrozenByte do you have any insight here?

@johnwry Don't forget to reload your theme using the app's admin interface in Nextcloud after you've edited your Twig templates.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

github-actions[bot] commented 1 year ago

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: