Jump to content

no output from $pages->find("template=category") on home.php


Recommended Posts

$pages->find() will find things; lots of things in some cases (pages) :D. You need to echo out the ouput.

Do you get any errors?

Is there really a template called "category"?

Does it have any unpublished and hidden pages using it?

In addition, have you read these documentation?




By the way, normally, you don't want to do something like $pages->find() without including a "limit"; It can find lots of things...and eat into your server resources, maybe hang your pages, hence, frustrate your web visitors, etc...


corrected typos

Edited by kongondo
Link to comment
Share on other sites

$pages->find is supposed to return multiple pages.

Use $pages->get to get only one page.

So when using find, you need to iterate over your pages:

$foundPages = $pages->find('template=category'); // Don't use $pages as variable name, it's reserved!
foreach ($foundPages as $p) {
  echo "Found page with title" . $p->title;
Link to comment
Share on other sites

Under the "Home" page, I have a few hidden pages, each with a template called "category". I just want to get the list of those pages filtering with "find("template=category")" and then loop through their children. I don't get anything by doing:

$cpages = $pages->find("template=category");
foreach ($cpages as $cpage){
echo $cpage->title;

And I don't get any error.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...