Page blacklisting helper module for ProcessWire.
With this simple module you can easily add pages to a global blacklist and use it for filtering of subsequent selector queries.
For ease of use, the modules adds a $pageBlacklist
variable to the template scope. Usualy you will only need one method:
$pageBlacklist->add($something);
$something
can be many things and is just a wraper for the internal API. Here is a list of possible values:
$pageBlacklist->add(1012);
// [integer]
// Will assume page with the ID '1212'.
$pageBlacklist->add($pageObject);
// [Page]
// Instance of Page adds this page.
$pageBlacklist->add($pageArray);
// [PageArray]
// Given an instance of PageArray, will add every page in that array.
// Also, you can add arrays containing IDs or Page objects:
$pageBlacklist->add(array(
1012, 1013, 1025
));
// or
$pageBlacklist->add(array(
$pageObject, $pageObject2, $pageObject3
));
Currently you are only able to remove pages by passing Page objects. More possibilities will be implemented soon:
$pageBlacklist->removePage($pageObject);
Also you can clear the complete blacklist:
$pageBlacklist->reset();
The simples approach is to add the $pageBlacklist
variable to any selector:
$list = $pages->find('template="basic-page"' . $pageBlacklist);
This will modify the selector and create something like:
'template="basic-page" id!=1012|1013|1025'
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.
tbc