2022-01-29, 13:26

Feb 27, 2012 — Notify Users module, ver. 0.5 released — user can choose between sending single message (...) »

2013-01-28, 08:32

19 студзеня 2013 у Гродне трагічна загінуў паэт, журналіст і мой сябар (...) »

2009-10-14, 07:19

The site Litaratura.org is devoted to Belarusian literary works and translations. (...) »

2009-01-12, 20:46

Late November 2008 marked the 20th anniversary of the official founding of the Belarusian (...) »

Registered User Area Log into This Site
Show Credits... Credits
~ / Public Domain Software / Extensions to Ditto / Obtaining Documents by OR-criterions $_
Obtaining Documents by OR-criterions
Click To View A Full Size Image...
2010-01-11, 06:53

Ditto’s filter excludes documents from the final dataset by a specific criterion. Multiple filter clauses are joined with logical OR operator so we are left within the final dataset with documents that meet NOT(criterion-1) AND NOT(criterion-2) ... AND NOT(criterion-N).

But what to do if we need to obtain documents meeting criterion-1 OR criterion-2 ... OR criterion-N?

The following is my solution based on PHx (luckily, Ditto snippet supports it by default).

Suppose, we need to obtain documents whose pagetitle contains „MODx” or whose firstname template variable contains „Joe”.

Ditto call

[[Ditto? &parents=`3,4,5` &display=`all` &tpl=`or-clause`]]

Chunk „or-clause”


We need custom PHx modifier „contains” — it should be implemented as a snippet named „phx:contains”.

Snippet „phx:contains”

<?php return strpos($output, $options) === FALSE ? '0' : '1'; ?>

How it works? The „contains” modifier transforms placeholder into 1 or 0 depending on whether it contains requested text or not. The „if” statement concatenates both transformed placeholders pagetitle and firstname — if it appears to be „00” (neither pagetitle contains „MODx” nor firstname contains „Joe”) no output is produced, otherwise (at least one condition is satisfied) regular output is rendered.