Jump to content
Mr. NiceGuy

$page->render() and $pages->find

Recommended Posts

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. 

 

 

Share this post


Link to post
Share on other sites

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

image.thumb.png.0345ac9d797826ffa2a11af330e84a5d.png

This is the front end: 

image.thumb.png.2de7dcb70bfb5b64a5ac226307c2e497.png

 

Share this post


Link to post
Share on other sites

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?

  • Like 1

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...