Mr. NiceGuy Posted February 13, 2020 Share Posted February 13, 2020 I'm having troubles using $pages->find and render(). I have a PageTable Field which holds pages that are saved under the admin. E.g $l has template "pagetableTMP" and is located under /admin/contentblocks/ if(count($page->content)>0){ foreach($page->content as $l){ $content .= $l->render(); } } In the frontend I render them like this where "content" is the PageTable field. In the template for $l there is this code: foreach ($pages->find('template=tmpname, sort=title') as $c) { echo " <tr class='hover:bg-gray-400'> <td class='py-4 px-6 border-b border-gray-300'>{$c->title}</td> .... </tr>"; } When I look at $l as a single page I get the correct output. However, when I look at the page with the $content field which should render $l I get no output at all because $pages is empty. The pages with template "tmpname" are not in the admin but are normal front-end pages. Link to comment Share on other sites More sharing options...
Mr. NiceGuy Posted February 14, 2020 Author Share Posted February 14, 2020 Did some more digging and turns out that $pages is available but it does not find the pages with the template that I am looking for. For example if I look for pages with template "basic-page" they are displayed in the PageTableExtended render, in the single page and in the frontend render. But if I look for the two specific templates in $pages-> that I want to display they are not shown. I checked the template name x times and also added include=hidden in the $selector and have no idea why they are not displayed. The name of the template is quite long but that should not matter, right? (16 chars). This is how it looks in PageTableExtended This is the front end: Link to comment Share on other sites More sharing options...
gmclelland Posted February 14, 2020 Share Posted February 14, 2020 I believe the problem is when the pages are stored under the admin branch it will apply admin permissions. I think you have use include=all in your find? 1 Link to comment Share on other sites More sharing options...
Mr. NiceGuy Posted February 25, 2020 Author Share Posted February 25, 2020 The pages itself were not in the admin branch. Eventually I realized that they were visible in the default language but not in the language I was viewing. Inlcude=all did indeed solve the problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now