Is it possible to specify a user defined template chunk for a specific document in a Ditto call, instead of alternating, first, last, alternative and all docs as Ditto currently allows? ie
for doc=3 (or some other filter) use tpl=y
The only thing I can think of is to put the doc at the end and use tplLast, but I don’t particularly want it at the end.
Mostly harmless.
Ditto iteration Counts: 0,1,2,3..
Example
class="news_item_[+ditto_iteration+]"
(
http://wiki.modxcms.com/index.php/PHx/CustomModifiers#phx:evenodd )
---
&tplAlt "User defined chunk to format every other document"
&tplCurrentDocument "User defined chunk to format the current document"
http://www.pogwatch.com/ditto/ditto-parameters.html
[+ditto_iteration+] only works inside tpl chunks AFAIK. It would
be nice if it worked in snippet call with
@CODE
You could do (inside tpl):
[+phx:if=`[+ditto_iteration+]`:ne=`2`:or:ne=`3`:then=`
Content
`:else=`
Content for 3rd and 4th item
`+]
OR simply check a TV value in the snippet call:
&tpl=`[+phx:if=`[*specialTv*]`:ne=`1`:then=`defaultTpl`:else=`specialTpl`+]`
This require you to have PHx plugin installed
http://modxcms.com/forums/index.php/topic,33316.msg238461.html#msg238461
Hope that helps!
Thanks, I’ll test it out.
Mostly harmless.
No luck:
[[Ditto? &startID=`0` &orderBy=`menuindex ASC` &depth=`1` &total=`5` &showInMenuOnly=`1` &tpl=`[+phx:if=`[*layout*]`:ne=`{{layout_single_col}}`:then=`content_cell_sidebar_tpl`:else=`content_cell_tpl`+]`]]
...where "layout" TV is dropdown list menu of layout chunks, {{layout_single_col}} and {{layout_col_sidebar}}
Ditto’s displaying `content_cell_sidebar_tpl` chunk for all docs. Have also tried using doc [*id*] without luck.
Mostly harmless.
Remove {{ }} brackets from the snippet call and your tv.
Thanks but no change. The problem with removing {{}} from my TV is that the TV dropdown allows switching between chunks for layout variation, so it kinda blows the functionality.
Mostly harmless.
Quote from: hotdiggity at Mar 04, 2010, 07:32 PM
Is it possible to specify a user defined template chunk for a specific document in a Ditto call, instead of alternating, first, last, alternative and all docs as Ditto currently allows? ie
for doc=3 (or some other filter) use tpl=y
The only thing I can think of is to put the doc at the end and use tplLast, but I don’t particularly want it at the end.
In MODx Revolution, the getResources snippet (a lightweight Ditto substitute) will let you use &tpl_{n} where n is the position of the item you want a specific tpl for. I don’t know of any way to do it with Ditto.
Quote from: hotdiggity at Mar 07, 2010, 11:25 PM
Thanks but no change. The problem with removing {{}} from my TV is that the TV dropdown allows switching between chunks for layout variation, so it kinda blows the functionality.
Ditto only needs the name for your listing tpl-chunk.
http://ditto.modxcms.com/tutorials/creating-a-custom-template.html
But did you see the PHx Example in my first reply?
Have a TV with input options: blue==1||different==2||3columns==3||etc==4
Then do
[[Ditto?... &tpl=`[*urTV:is=`1`:then=`blue`:else=``*][*urTV:is=`2`:then=`different`:else=``*]`...]]
Maybe I’m misunderstanding, but I don’t think any of that will work because it will all be evaluated when the Ditto tag is processed (before any items are retrieved) so all items will get the same Tpl.
The only way I can think of to do it with Ditto is to just refer to the TV in the &tpl parameter:
and then put the actual tpl HTML code in the TV rather than in a chunk.
[[Ditto? ... &tpl=`[*layout:is=`layout_single_col`:then=`content_cell_tpl`:else=`content_cell_sidebar_tpl`*]`]] didn’t work either...
Mostly harmless.