Jump to content
SoccerGuy3

Problem with $page->find()

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!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...