2018-08-17, 20:36

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 / Glossary Tutorial $_
Glossary Tutorial
Click To View A Full Size Image...
2010-01-10, 18:43

This is a comprehensive tutorial how to build a glossary (doc id=109) with active/ inactive letter buttons depending on actual presence of documents in container(s) being the subject of search (id=49).

Example of directory structure

Makers (id=49)
  Maker1
  Maker2
  ...
Glossary (id=109)
  A
  B
  C
  ...
  Z

We will need three chunks, for example, named: „empty”, „one-letter”, and „index”.

Chunk „empty”

[+none+]

The above is used for generating empty output — „none” placeholder stands for non-existent template variable which, at a runtime, will be replaced by Ditto with empty text.

Chunk „one-letter”

<li><a href="[~[+id+]~]">[+lastname+]</a></li>

This chunk is used for generating listing of documents whose filtered template variable (lastname) starts with specific letter.

We need to put into content field of each A, B, C, ..., Z document the following Ditto call:

Single letter listing

<ul>[[Ditto? &parents=`49` &depth=`1` &display=`all` &tpl=`one-letter` &noResults=`empty` &filter=`lastname,[*pagetitle*],11` &sortBy=`lastname` &sortDir=`ASC`]]</ul>

Next we need to build an index in „Glossary” document; for this purpose we put into the content of this document the following Ditto call:

Glossary buttons

[[Ditto? &parents=`109` &depth=`1` &display=`all` &tpl=`index` &sortBy=`pagetitle` &sortDir=`ASC`]]

And finally, the most sophisticated part of this task:

Chunk „index”

[+phx:if=`[[Ditto? &parents=`49` &depth=`1` &tpl=`one-letter` &noResults=`empty` &filter=`lastname,[+pagetitle+],11`]]`:is=``:then=`[+pagetitle+]`:else=`<a href="[~[+id+]~]">[+pagetitle+]</a>`+]

This solution was originally posted to this thread on MODx Forum.