Page list template that filters data based on a custom page attribute

Permalink 1 user found helpful
A simple template for the page list block that filters your data based on the selection of a custom page attribute, in this case called 'Meet the team'.

It simply runs the for loop, and only returns data if the 'meet_the_team' attribute has been checked. It works in the same way as the in built 'is_featured' attribute, but for cases when this is already being used elsewhere.

A fairly simple one this... but something I struggled to find any documentation on, so hopefully helpful!

I've attached the template as a .txt file here.

defined('C5_EXECUTE') or die(_("Access Denied."));
$textHelper = Loader::helper("text"); 
$imgHelper = Loader::helper('image'); 
if (count($cArray) > 0) { ?>
for ($i = 0; $i < count($cArray); $i++ ) {
   $cobj = $cArray[$i]; 
   $title = $cobj->getCollectionName();
   $meet_team = $cobj->getAttribute('meet_the_team');
   <?php  if ($meet_team == '1') { ?>  
        <div class="person">
          <img src="<?php echo $imgHelper->getThumbnail($cobj->getAttribute('page_thumbnail'), 200, 999)->src ?>" alt="<?php echo $title ?>" />
          <p><?php echo $title ?></p>

1 Attachment

View Replies: