Select Page Attribute / Custom Attributes / Site Map Filter by Page Type

Permalink
I'm building a page type that would include a "Featured Article" on this page. I know I could grab a list of all pages with the page type of article, and then find the ones that have a special attribute of 'featured' set to true. But in this case, I cannot have more than one featured article, and going this route would allow the user to add multiple featured articles.

Which brings me to idea 2. Somehow have a 'Select Featured' article from composer view for the page that will list all the articles. It would be a page selector that only brings up pages with the page type of article, then the user could select which article to use as the featured article?

Does this make sense? Is there a way to do this natively? Another route may be to build a block that has a composer view, that allows use to select a page (instead of it being an attribute)... but that would still leave the last part and that is only letting the page selector show pages with a certain page type. Is that doable?

ob7dev
 
mrjcgoodwin replied on at Permalink Best Answer Reply
mrjcgoodwin
Could you just make a custom attribute of 'featured' but only ever select/display the most recent one. So if you want to make a new featured article it would override past ones?
ob7dev replied on at Permalink Reply
ob7dev
Genius.
ob7dev replied on at Permalink Reply
ob7dev
Heres how I implented your suggeston:
$pageList = new \Concrete\Core\Page\PageList();
   $pageList->filterByPageTypeHandle('event');
   $pageList->sortByPublicDate();  // this way the last item to be looped through is most recent post
   $results = $pageList->getResults();
   foreach ($results as $result):
      $isFeatured = $result->getAttribute('event_featured');
      if($isFeatured) {
         //Make things happen
      }
   endforeach;