Jump to content



Recommended Posts

Hey there,

this is a little helper I'm using on some sites, thougth mabe someone is interested.

With this simple module you can easily add pages to a global blacklist and use it for filtering of subsequent selector queries.

The idea is the following: 

Let's assume you have something like a blog. You have a simple list of articles in the main column of the page, showing the newest articles from every category.

Also you have a small teaser on the right sidebar, showing the latest articles filed under a special category, like news.

Now you possibly don't want that teaser to include articles, which are already in the big list in the main column.

PageBlacklist is a small module, helping you to implement blacklisting on for such cases.

Assuming the scenario on the top, your code could look something like this:

// Retrieve the maincol list and add to blacklist
$bigList = $pages->find('template=article, sort=-created');

// Possibly you will output $bigList here

// Retrieve the sidecol teaser, excluding blacklisted articles
$teaser = $pages->find('template=article, parent=news, sort=-created, ' . $pageBlacklist);

// Basically, this will alter the selector to something like:
// 'template=article, parent=news, sort=-created, id!=1012,1031,1153'

I would love to hear ideas to improve this helpfull little module. 

You can find PageBlacklist on GitHub: https://github.com/tsdtsdtsd/PageBlacklist

  • Like 1
Link to comment
Share on other sites

Oh, and here is already a downer for you: Beware of thy cache!

When using markup cache, this module is naturally not able to collect the pages from cached code. Subsequent selectors may include pages from cached content.

Currently I'm storing some metainfo to the cache as an addition to evade the problem on personal projects. Not sure how this could be handled more globally.

Link to comment
Share on other sites

Hey tpr,

you are absolutely right and tbh I didn't think of that option. The reason is maybe a little specific to my projects. 

Usualy I build my sites out of individual elements/widgets, which are placed on/called by the templates. These elements get rendered by a new TemplateFile object. I could pass the $bigList along to the $teaser to use your method too.

Guess it made more sense for me to make the elements as autonomous as possible, with little to no dependencies. So they rather fetch information as they need it, instead of depending on the template. Thought that makes my code a little better readable and nicer to follow. And I have a reusable workflow ;)


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...