i ve setup a route like /keyword -> /blog/keyword in the site.yaml. If the the page is invoked by this route the following find doesnt work as expected:
<div class="links">
{% set _p_links = page.find('/_footer/links') %}
{{_p_links.content}}
</div>
The weired thing is that the _p_links object isn’t empty. It points to the /blog/keyword/blog.md.
Does a custom route break such find instructions in general?
@npetri Is ‘/_footer/links’ located at the top level of folder ‘/user/pages’? Like ‘/user/pages/_footer/links’.
page.find('/...) Starts searching for a page from the root of the pages folder.
When I use your script in the ‘blog-skeleton’ in ‘blog.html.twig’ and use “page.find(’/blog/hero-classes’)”, it correctly prints the content of page ‘hero-classes’, which is at ‘user/pages/01.blog/hero-classes’
Uhh… no, “page.find(’./hero-classes’)” does not find it…
If the file cannot be found, it seems to return a reference to the current page. Not sure if that is logical…
Yea the /_footer/links’ is within the /usr/page folder. Otherwise it could never be found, but it works when in ‘normal’ cases. But it behave different if its used in a context of a custom a route. And like u also discovered, it returns an unexpected page, the current one. In my case, the page content of a blog item was pasted in the footer twice, bcs i have two of this find calls there.
Wow, thank u for ur effort. The code block that doesnt work is inside the footer partial that is used by the base.html.twig. The modular page that is called via / which points to /pages/01.home is extending this base.html.twig.
I can share my whole grav installation as a zip if u want to reproduce it.
Preliminary result: I checked some options that maybe related to routes. I had disabled the default language in route. So i enabled this option and now the page.find() call works as expected. I will do some further test…
its all related to the option routeable: false. However, in this case page.find() deliver the current page as a fallback. I don’t know if this is suppost to be.
This option was set in the related files by accident. Probably, it was already set in the markdown file that i used as template for this files. In the admin panel, non routable pages have a red plus instead of grey or blue, but i didn’t get it.