Jump to content

$pages->find("template=xxxx") not working for certain template


Tyssen
 Share

Recommended Posts

I'm trying to fetch an array of pages that use a certain template with:

$my_array = $pages->find("template=xxxx");

But for some reason, it won't return anything for the template that I'm targeting. If I change the template name to my basic page or news templates, for example, I get a list of pages output, but not for the template I want.

Is there some setting I've inadvertently set that would cause the template's pages to not display? The template is being used for pages on the site and they display OK as single entry pages.

Or could it be related to an issue I had with the same template yesterday where I was adding a new field to the page, and then when I went to edit the page with content in the new field, I'd get returned to the same page I was on, i.e. /processwire/page/edit/?id=XXXX but it would display the 404 template instead? And the data I'd tried to enter wouldn't be saved.

The template only has title, multiplier, table and file fields attached to it. And the table field is also modified by the TableCSVImportExport module.

Link to comment
Share on other sites

Is it a case of:

 it won't return anything for the template that I'm targeting. 

Or...?

...that would cause the template's pages to not display

If you are able to fetch (i.e. $my_array is NOT empty) but not display, then, as suggested, check the template file. If you cannot access (i.e. returns nothing), then check access controls, e.g. are the pages hidden? For instance, 'find' will not retrieve hidden pages although 'get' will...

  • Like 2
Link to comment
Share on other sites

Just in case anyone else stumbles on this.

Adding include=hidden or include=all to your selector can help troubleshoot when you aren't getting any results.

$my_array = $pages->find("template=xxxx, include=hidden");
  • Like 3
Link to comment
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
 Share

×
×
  • Create New...