<![CDATA[ Ditto and AtoZ (Solved) - My Forums]]> https://forums.modx.com/thread/?thread=42614 <![CDATA[Re: Ditto and AtoZ]]> https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246549
thanks for the how-to!
For this moment there was no any working solutions (snippets or plugins) for this task, but now it is.
...would the a2z Snippet be an alternative for this? http://modxcms.com/forums/index.php/topic,36667.msg221349.html#msg221349]]>
anonymized-26931 Dec 28, 2009, 04:13 AM https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246549
<![CDATA[Re: Ditto and AtoZ]]> https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246548 nice to hear that it works for you. Please mark the thread as "solved" or so thus signaling for others that it comprises working solution.
(In my spare time, I will copy document structure from your post and put this tutorial onto my site where I am collecting the most interesting solutions provided to this forum.)]]>
Alik Dec 28, 2009, 04:08 AM https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246548
<![CDATA[Re: Ditto and AtoZ]]> https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246547 For this moment there was no any working solutions (snippets or plugins) for this task, but now it is.]]> labasus Dec 28, 2009, 03:28 AM https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246547 <![CDATA[Re: Ditto and AtoZ]]> https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246546
Prerequisites are three chunks, for example, named: "empty", "one-letter", and "index".

"empty" chunk is used for generating empty output -- its content should be something like:
[+none+]

where [+none+] stands for non-existent TV name which, at a runtime, will be replaced by Ditto with empty text.

"one-letter" chunk is used for generating listing of documents whose filtered TV (lastname in the above-post) starts with specific letter, its sample content might be as follows:
<li><a href="[~[+id+]~]">[+lastname+]</a></li>


"index" is used for generating A B C... Z active/inactive buttons, I will build its content at the end.

You need to put into content field of each A, B, C, ..., Z document Ditto call:
<ul>[[Ditto? &parents=`49` &depth=`1` &display=`all` &tpl=`one-letter` &noResults=`empty` &filter=`lastname,[*pagetitle*],11` &sortBy=`lastname` &sortDir=`ASC`]]</ul>


Next you need to build A B C ... Z index in your ABC document; for this purpose place into the content of this doc the following Ditto call:
<!-- manually build ALL link here -->
[[Ditto? &parents=`109` &depth=`1` &display=`all` &tpl=`index` &sortBy=`pagetitle` &sortDir=`ASC`]]


And finally, "index" chunk, the most sophisticated part of this task:
[+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>`+]

Of course, the above only looks like a sophisticated thing, but actually it is a simple if-then-else statement expressed in PHx terms. Before building each letter-button in the index, you need to check whether documents starting from this letter exist or not. This part is performed by if-part of PHx. If Ditto returns no output (there are no documents), then the letter as a static text is rendered (then-part of PHx). Otherwise (else-part of PHx), linked letter is rendered. Done.
The advantage of this solution is that it requires neither extender nor ugly-looking url stuff.

Edit: this was a long post so some inconsistencies appeared in it, but hope I removed them all.]]>
Alik Dec 27, 2009, 05:03 PM https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246546
<![CDATA[Ditto and AtoZ (Solved)]]> https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246545
Header buttons: ALL | A | B | C | D | ... | Z

-----
Document tree

Makers (49)
Maker1
Maker2
...
ABC (109)
A
B
C
...
Z

Template
-----
<!-- Header
<ul class="abecele">
<li><a href="[~[*id*]~]">ALL</a></li>
[!Ditto? &id=`abc` &parents=`109` &tpl=`abecele` &sortBy=`pagetitle` &sortDir=`ASC`!]
</ul> -->

<!--Catalog output
<ul class="abecele">
[[Ditto? &parents=`49` &tpl=`makers` &sortBy=`pagetitle` &sortDir=`ASC` &paginate=`1` &extenders=`request` ]]
</ul> -->
-----

Chunk - "abecele"
<li><a href="[~[*id*]~]&ditto_filter=lastname,[+pagetitle+],11">[+pagetitle+]</a></li>

Chunk - "makers"
<li><a href="[~[+id+]~]">[+lastname+] [+name+]</a></li>

-----

All works except active and inactive alphabet button links.
I’ve tried to make "abecele" chunk:
[+phx:if=`[+total+]`:is=`0`:then=`<li>[+pagetitle+]</li>`:else=`<li><a href="[~[*id*]~]&ditto_filter=lastname,[+pagetitle+],11">[+pagetitle+]</a></li>`+]


But it doesn’t work, any suggestions?]]>
labasus Dec 27, 2009, 01:45 PM https://forums.modx.com/thread/42614/ditto-and-atoz-solved#dis-post-246545