Checking current pageID against parent page ID down sitemap tree
Permalink
Hi,
I'm trying to hard code a pagelist that shows all pages with page type 'News'. I've created a custom attribute select list for my client to choose the type of news it is i.e.
- Production
- Stage
- Technical
However, I need to show only the 'Technical' news in the 'Technical section whether that is on the Technical page itself or several levels down i.e.
- Technical
- - Subpage 1
- - - Sub subpage 1
- - - Sub subpage 2
- - Subpage 2
etc.
The same with Stage and Production news. My idea was to hardcode in a pagelist block with a pagelist, and then write some logic in a pagelist custom template that uses the parent page ID for the current page.
The logic would be something like this:
Does anyone know how I'd do this? Not sure how to grab the parent page ID for a current page if it's far down the sitemap tree.
Thanks
osu
I'm trying to hard code a pagelist that shows all pages with page type 'News'. I've created a custom attribute select list for my client to choose the type of news it is i.e.
- Production
- Stage
- Technical
However, I need to show only the 'Technical' news in the 'Technical section whether that is on the Technical page itself or several levels down i.e.
- Technical
- - Subpage 1
- - - Sub subpage 1
- - - Sub subpage 2
- - Subpage 2
etc.
The same with Stage and Production news. My idea was to hardcode in a pagelist block with a pagelist, and then write some logic in a pagelist custom template that uses the parent page ID for the current page.
The logic would be something like this:
Does anyone know how I'd do this? Not sure how to grab the parent page ID for a current page if it's far down the sitemap tree.
Thanks
osu
The "validPageObj" method simply checks that the argument is a valid Page object and is not empty/has no errors.
So in this example, you would get a Page object by the ID of each of those parent pages you mentioned and feed it to this method.