2010-09-08, 14:15

Aug 30, 2010 — glossaryFilter has been updated — now it has new forceUTF8 parameter. (...) »

2009-11-03, 08:40

On November 1, 2009, I bought and configured an additional domain for all web services (...) »

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
Show Donation/ Payment Page... Donate/ Pay
Worthwhile Software
Refresh My Local Time (GMT+1)... 2010-09-08, 14:15
  • China (2)
    Japan (1)
    Russian Federation (1)
    United States (5)
  • Today (142)
  • Yesterday (209)
~ / 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.

Write a comment
  • Required fields are marked with *.
  • Comments are published after the approval of the site moderator, who is a human rather than a wind-fast computer program so please be patient. Off-topic comments are definitely removed.

* Code:
 
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...