Forum

Thread tagged as: Question

Using perch_custom_content only for immediate child pages

I have a folder called alumni with a folder inside of it called profiles.

I wish to retrieve content from the /alumni page only and not any pages under /alumni/profiles.

My current code, which grabs all pages:

<?php perch_content_custom('Header', array('page' => '/alumni/*', 'template' => 'article_card.html')); ?>

How can I specify that I only want the pages residing in /alumni and not also /alumni/profiles ?

Something similar to the following would be ideal:

<?php perch_content_custom('Header', array('page' => '/alumni/*/', 'template' => 'article_card.html')); ?>
Nicolai Davies

Nicolai Davies 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's not a way to do that.

Could I request this as a feature?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can, but I can't make any promises at this stage.

Finally found a solution to this: Instead of using perch_content_custom I switched to perch_pages_navigation:

<?php perch_pages_navigation(array(
    'levels' => 1,
    'from-path' => '*',
    'template' => 'section.html',
    )); ?>

Content like a background image, description and header are now added through perch_page_attributes, which can be accessed in the navigation template with <perch:pages ... />

For future reference for anyone trying to do the same.