2010-09-08, 14:25

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:25
  • United States (4)
  • Today (143)
  • Yesterday (209)
~ / 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.

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...