Page list filter with custom select attribute?

Permalink
I've gotten the page list to filter based on a custom checkbox attribute. What I'd really like to do is filter the page list based on a custom select attribute. Has anyone done this that can offer guidance?

Thanks,

-Foster

foster
 
jordanlev replied on at Permalink Reply
jordanlev
foster replied on at Permalink Reply
foster
Awesome! I got it to work by editing your Related Content Links block.

One question:
Is there a way to keep the current page from showing up in the list of related content links?

For further clarification - I am working on a portfolio site for a firm that is posting work for about 100 clients, each client having a separate page with different types of work. So we might show work for Client A in Disciplines T, U and V.
I edited your Related Content Links block to show:
"Client A can be seen in: Branding Packaging Logos"
but I'd like for the Branding link to not be seen on the Branding page.

I'm still learning php - so hopefully this code is somewhat efficient. Any pointers are more than welcome.

<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<?php $title = htmlspecialchars($page->getCollectionName(), ENT_QUOTES, APP_CHARSET); ?>
<div class="related_content_links">
   <?php if (!empty($title)): ?>
   <?php endif; ?>
   <div class="disc_cont">
      <div class="disc_heading"><?php echo $title; ?> can be seen in: </div>
      <div class="discipline">   
         <ul>
            <?php
            foreach ($pages as $page):
               $link = $nh->getLinkToCollection($page);
               $title = htmlspecialchars($page->getCollectionName(), ENT_QUOTES, APP_CHARSET);
               $date = empty($dateFormat) ? '' : date($dateFormat, strtotime($page->getCollectionDatePublic()));
               $dp = $page->getAttribute('discipline');
jordanlev replied on at Permalink Best Answer Reply
jordanlev
If I'm understanding things correctly, it should be fairly easy. Try adding this new line above the existing "foreach ($pages as $page):" line:
$currentPageCID = Page::getCurrentPage()->getCollectionID();

...and then add this new line *below* the existing "foreach ($pages as $page):" line:
if ($currentPageCID == $page->getCollectionID()) {
    //skip this item because it is the current page
    continue;
}
foster replied on at Permalink Reply
foster
Amazing! Totally works!!!

Thank you so much for the help on this specific question - and for the tons of other content you've posted over the years!

-Foster
jordanlev replied on at Permalink Reply
jordanlev
You're welcome! Glad I could be of help.