Jump to content

Problem with $page->find()


SoccerGuy3
 Share

Recommended Posts

I've used this same code on lots of sites, but for some reason this new site is giving me grief!

So with this page tree:

Home
	Page
	Page
	Category
		2nd Level Page
		2nd Level Page
	Blog
		Article
		Article

On the home page I have:

foreach ($page->find("parent=/blog/, limit=3, include=all") AS $oneBlog) {
	echo $oneBlog->output_field;
}

And it works fine.

But when I put that same code on a 2nd Level Page, it finds nothing and therefore the 2nd level page is blank.

One other issue on this site. On all previous uses of this code I have used $pages-> instead of $page-> and it worked fine. On this site I am getting an error when using $pages: "Error: Uncaught Error: Call to a member function find() on array in /home..."

Could this be a bad install of PW or something? I am missing something obvious? Help!

Link to comment
Share on other sites

$page->find()start from $page
if $page != home { $page->find( 'parnet=/blog/' ) will.alwayse return NO things }

so >>> u.must use $pages->find()
noT $page->find() !!

OAR u can.uses $pages->get('/blog/')->children( 'limit=3, include=all' )

if usesing $pages say shits bout array it mean yoU write-over it some where 
>>> u did a $pages = array some.where !

fix that.or u can uses wire( 'pages ')->find(' you.selectoro stuff here ');
or functiones api pages()->find( 'selectros in this' ) 
amen

  • Like 7
Link to comment
Share on other sites

14 minutes ago, WillyC said:

if usesing $pages say shits bout array it mean yoU write-over it some where 
>>> u did a $pages = array some.where !

BINGO!! That was it. I had picked up some code from a (former) employee for generating the nav bar and he had used $pages as a array/var. Changed his code from $pages to $navPages and my code now works!!!

Thanks for pointing me in the right direction!

  • Like 1
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...