Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Can't find() unless I rename

Started by Muut Archive 10 years ago · 5 replies · 279 views
10 years ago

This is going to sound crazy.

I was doing this in a macro:

TWIG
{% set showPages = grav.pages.root.find('/shows/active-shows').children %}

I was surprised and frustrated that it didnt work because I was doing the same thing in a template for a different dir. I was putting this into a macro because I need to use it in more than one place.

It was simply not finding those children. And I kid you not, on a whim I renamed the directories in '/shows/active-shows' and then they showed up! I renamed them back to what they were originally, they still were find()able.

I was dumping the cache during this troubleshooting process, and I also have caching turn off in the config. Any thoughts?

10 years ago

What were they named before and what were they named after? Because that doesn't make a whole lot of sense if your cache was off too.

10 years ago

Oh, they were named:

boring-show/
funny-show/
crazy-show/

I renamed them to:

01.boring-show/
02.funny-show/
03.crazy-show/

And then they worked! Then I renamed them back to the original.. And they still worked! Yes.. shocked. Dunno if it matters, I did make the original dirs via the file browser in ubuntu and I renamed them, and back again in sublime. I didnt check permissions or anything before I did it, but they should've been ok.

10 years ago

Ok, this makes a little more sense. The numeric prefix is a quick way of denoting whether or not the page is visible in the menu. This is handled in the navigation Twig with the {% if p.children.visible.count > 0 %} or something like that.

10 years ago

Ok that's a relief, I thought it was something worse. But after I switched it back to the base name without the numeric prefix it was still able to find the pages. Why might that be?

10 years ago

Maybe you are now using code that is not checking the visibility? Maybe after clearing the cache, you won't be able to see them again? Maybe you added a manual visibility override to these pages?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1366 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago