2018-04-27, 08:34

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
Worthwhile Services
Refresh My Local Time (GMT+1)... Apr 27, 2018 — 08:34
  • Austria (1)
    Poland (1)
    Russian Federation (2)
    United States (6)
  • Today (108)
  • Yesterday (451)
~ / 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”

[+phx:if=`[+pagetitle:contains=`MODx`+][+firstname:contains=`Joe`+]`:is=`00`:then=``:else=`{{chunk-to-display-doc}}`+]

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.

Click to show a form...Click to hide the form... Write a comment
  • Required fields are marked with *.
  • Comments are published after the approval of the site owner, who is a human rather than a wind-fast computer program so please be patient.

* Code:
 
Get another image...Enter this code into the appropriate field of the form while submitting an e-mail or a comment. If you have trouble with reading it, generate another...