Jump to content

Page Reference Selector counting grandchildren


hezmann
 Share

Recommended Posts

I have the following page structure

  • Continents
    • Countries
      • Regions

I then have pages "walks" which has a multi-select Page Reference field Regions (I've tried using dynamic fields for this but it wasn't accomplishing what I needed) which has the regions listed by country and then the region (continent is more for searching later on so doesn't need to be seen here).

I'm trying to get a count of firstly all the walks within a continent, then country, then region but can't seem to figure out the selector for this.  

Thanks,

Heather

 

Link to comment
Share on other sites

On 2/1/2018 at 1:23 AM, hezmann said:

I've tried using dynamic fields for this but it wasn't accomplishing what I needed)

To be honest, I'm having a hard time understanding exactly what you need to accomplish :). Even a simple mockup would help. Anyway, to your question.

I'm having a hard time understanding your setup. For instance, you say:

On 2/1/2018 at 1:23 AM, hezmann said:

I then have pages "walks" which has a multi-select Page Reference field Regions

Do you have a single page called walks? (you say has a multi-selected page reference) OR you have multiple pages called walks. (you say I then have pages...).

Secondly, where is this "walks"?

Is the multi-select page reference field attached to the templates of both Continents and Countries? And more?

I'm asking in order to give you a definitive answer.  Irrespective, I believe what you want is either $pages->count("selector here") OR $page->numChildren("selector here"). Please note the differences as per the docs below:

http://processwire.com/api/ref/page/num-children/

http://processwire.com/api/ref/pages/count/

 

  • 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

×
×
  • Create New...