Forum
Get Parent page title based on subpage pagePath or pageID
I have a php page using perch_content_custom to display subpage content in an overlay via ajax call.
How can I get the pages Parent title?
I was hoping I could get the parent page info by passing the subpage pagePath or pageID to a function
Thanks
You can get the page title with
perch_page_attribute('pageTitle')
, which will also accept a pageID:Thanks Drew. It is the parent page Title I need but the parentPage ID is not present in the sub page content array? How can I get the parent page ID when I am pulling in subpage content via ajax?
Yes, you should have the parent ID available in the details for the page.
Hi Drew I was hoping you'd say that however I'm not getting the parent ID -
Gives me var_dump -
Am I missing something here? I'm not getting the parentID is this array.
cheers Keith
Hi Drew I assume I'm not getting the parentID as I'm only getting content not current page details?
Subpage content is loaded by ajax into overlay after the actual page is loaded. Next and Prev links then run ajax call to get next or previous subpage which is loaded into existing overlay without changing the parent web page. Hope that makes some sense!
Would I therefore need to use PHP to run connect to perch db and run custom mysql query eg. something like select pageParentID where pageID = 123
Or is there a perch function that would return the pageParentID where pageID = 123
Thanks
Keith
Have you tried using the navigation functions? Those give you the page information, not the content functions.
Ah ok I'll take a look at that. Thanks
Ok I've nearly got it but...
This returns an array with page details including pageParentID which is good.
This outputs to the screen the pageParentTitle
I can't seem to create a variable $theParentTitle so I can echo it out in page -
I would like to do something like
Then
Hope that makes some sense.
Keith
Almost there...
should work.
The
, true
as the last parameter of the function returns the value instead of echoing.Thanks Duncan that's got it. Keith