Jump to content

List child pages of a specific path


Peter Knight
 Share

Recommended Posts

I have a structure as follows

Department A
- meet 
 -- John
 -- Will

Department B
- meet
 -- Lisa
 -- Amy

I want to give Department A and B the same template with a general selector that will list only the people in its child 'meet' folder.

Normally I'd just specify a parent id but because both Departments need to list their people, I am looking to list by a path.

<?php 
$pages->find("template=a-person");
foreach($page->children(has_parent=/meet/) as $meet) {
echo "

IE

Department A will only list John and Will

Department B will only list Lisa and Amy

I'll keep hammering away at it ...

 

 

 

 

Link to comment
Share on other sites

I can't use 

has_parent=id because I need my output to work for 2 different pages

Essentially I want to do this...

  • Get any child pages within a folder called "meet"

Both Department A and Department B have their own "meet" folder and must only list the contents of their own meet folder

 

Link to comment
Share on other sites

DepId would be a variable of course. Listing all persons would be as easy as just "template=person"

But maybe you have a different template setup. I thought departments have template dep and meet have template persons and persons have template person.

Is it different?

Link to comment
Share on other sites

Just now, bernhard said:

DepId would be a variable of course. Listing all persons would be as easy as just "template=person"

But maybe you have a different template setup. I thought departments have template dep and meet have template persons and persons have template person.

Is it different?

1

That's the correct structure.

I see what you mean about Depid being a variable. I'll try that.

 

Link to comment
Share on other sites

5 minutes ago, Peter Knight said:

Thank you both. Got it working in the end with a page ID as a variable. Came back here and noticed your approaches are more efficient.

@bernhard I'm not familiar with selector properties being in square brackets. Is this called Sub-selectors: selectors within selectors on the docs page?

 

No, it's selectors as associative arrays:

https://processwire.com/blog/posts/processwire-3.0.13-selector-upgrades-and-new-form-builder-version/#new-selectors-as-associative-arrays

  • Like 2
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...