How do I exclude featured pages from a page list block?

I have multiple page list blocks on the homepage and one is set to show featured pages. When I feature new content, the featured pages show in my other page list blocks right below it. How would I exclude featured pages from it? Someone else suggested to use $list->filterByIsFeatured(false); in the blocks template file but it doesn’t work.

You might have to put in 0?

This is how it looks in the block controller:

       if ($this->displayFeaturedOnly == 1) {
            $cak = CollectionAttributeKey::getByHandle('is_featured');
            if (is_object($cak)) {
                $this->list->filterByIsFeatured(1);
            }
        }

It might be too late to do that in the view though. The view is iterating over $pages object.

You might be able to invoke the controller from the view and then modify the list there or something? It’s a little hacky though.

I think it would be useful that, if there’s going to be a “show only featured” option, there should probably be an “exclude featured” baked into the block edit interface as well, because this comes up a lot actually.

Recommend making a feature request here:

1 Like

0 doesn’t make a difference but I was able to exclude featured pages from my other page lists using this small change in the controller:

        if ($this->displayFeaturedOnly == 1) {
            $cak = CollectionAttributeKey::getByHandle('is_featured');
            if (is_object($cak)) {
                $this->list->filterByIsFeatured(1);
            }
        } elseif ($c->getCollectionID() == 1) {
          $this->list->filterByIsFeatured(0);
        }
1 Like

Nice! Glad you could get it all sorted.

1 Like