Examples
This is a user-contributed Extra. If you find issues or would like more info or help, please contact the author.
A Ditto "image sub menu"
the Ditto call
[[Ditto? &id=`im[*id*]` &parents=`27` &depth=`1` &hideFolders=`1` &outerTpl=`image-menu-wrapper` &tpl=`image-menu-row` &noResults=` ` &orderBy=`menuindex ASC` &filter=`id,[*id*],2` ]]
Notes:
- the 27 in
&parents=`27`
is the Resource ID of the relevant parent folder &filter=`id,[*id*],2`
excludes the current resource from the menu
the outer wrapper template chunk
<div class="grid clearfix"> <ul> [+wrapper+] </ul> </div>
the row template chunk
<li><a href="[~[+id+]~]" title="[+pagetitle+]"[[if? &is=`[+link_attributes+]:!empty` &then=`[+link_attributes+]`]]><img src="[[phpthumb? &input=`[+my-image+]` &options=`w=400,h=280,q=90,zc=1,far=C`]]" alt="[+pagetitle+] image" /><span><strong>[[if? &is=`[+menutitle+]:!empty` &then=`[+menutitle+]` &else=`[+pagetitle+]`]]</strong></span></a></li>
Notes:
[+my-image+]
refers to a template variable called my-image with input type image- the phpthumb snippet is used to create a thumbnail of the my-image image
- the IF snippet is used to include the menutitle if it is not empty
A Ditto news menu
the Ditto call
[[Ditto? &id=`page` &parents=`97` &depth=`0` &display=`10` &hideFolders=`1` &showPublishedOnly=`1` &showInMenuOnly=`1` &paginate=`1` &paginateAlwaysShowLinks=`1` &outerTpl=`news-menu-wrapper` &tpl=`news-menu-row` &noResults=`news-menu-NO` &tplPaginatePage=`pagination-page` &tplPaginateCurrentPage=`pagination-current` &tplPaginatePrevious=`pagination-prev` &tplPaginatePreviousOff=`pagination-prevOff` &tplPaginateNext=`pagination-next` &tplPaginateNextOff=`pagination-nextOff` &orderBy=`pub_date DESC, pagetitle DESC` &filter=`news-cat,Latest,7` ]]
Notes:
- the page in
&id=`page`
indicates the label added to the page url - eg http://domain.com/news?page_start=10 - the 97 in
&parents=`97
is the Resource ID of the relevant parent folder &paginate=`1`
and&paginateAlwaysShowLinks=`1`
turns on pagination, so the menu will show on multiple pages- the 10 in
&display=`10`
means that 10 items will show on each paginated page &filter=`news-cat,Latest,7`
filters the menu so that only news items that have the "Latest" option selected in the "news-cat" template variable will be included in the results&tplPaginatePage=`pagination-page`
is a chunk with content<a class="ditto_page" href="[+url+]"><span>[+page+]</span></a>
&tplPaginateCurrentPage=`pagination-current`
is a chunk with content<span class="ditto_currentpage"><b>[+page+]</b></span>
&tplPaginatePrevious=`pagination-prev`
is a chunk with content<a href="[+url+]" class="prev ditto_prev_link" title="previous">◄</a>
&tplPaginatePreviousOff=`pagination-prevOff`
is a chunk with content<span class="prev ditto_prev_off ditto_off">◄</span>
&tplPaginateNext=`pagination-next`
is a chunk with content<a href="[+url+]" class="next ditto_next_link" title="next">►</a>
&tplPaginateNextOff=`pagination-nextOff`
is a chunk with content<span class="next ditto_next_off ditto_off">►</span>
the outer wrapper template chunk
<div class="newsbox"> [+wrapper+] </div> [+phx:if=`[+page_totalPages+]`:el=`1`:then=``:else=`<div class="pager"> [+page_previous+] [+page_pages+] [+page_next+] </div>`+]
the row template chunk
<article class="newsitem"> <h2><a href="[~[+id+]~]" title="[+pagetitle+]">[+pagetitle+]</a> <span>[+pub_date:date=`%B %e, %Y`+]</span></h2> [+content:is=``:then=``:else=`<p>[+content:word_limit=`50`:striptags+] <span class="more"><a href="[~[+id+]~]" title="read more">more</a></span></p>`+] </article>
Notes:
[+content:word_limit=`50`:striptags+]
uses 2 different phx snippets joined in the one call. "word_limit" is used the include only the forst 50 words from the content variable. "striptags" is used to remove any html from the content
the no items template chunk
<p>No current items.</p>
A Ditto menu that adds checkbox options into an eForm form
the Ditto call
[[Ditto? &id=`ef[*id*]` &parents=`93` &depth=`0` &hideFolders=`0` &outerTpl=`emailform-menu-wrapper` &tpl=`emailform-menu-row` &noResults=` ` &orderBy=`pagetitle ASC` ]]
Notes:
- the 93 in
&parents=`93`
is the Resource ID of the relevant parent folder
the outer wrapper template chunk
<div class="wrap clearfix"> <label>Options</label> [+wrapper+] </div>
the row template chunk
<div class="row"> <label><input name="options[]" type="checkbox" value="[+pagetitle+]" /><span>[[if? &is=`[+menutitle+]:!empty` &then=`[+menutitle+]` &else=`[+pagetitle+]`]]</span></label> </div>
A Ditto rss menu
the Ditto call
[!Ditto? &id=`rss` &startID=`0` &depth=`0` &showPublishedOnly=`1` &showInMenuOnly=`1` &outerTpl=`rss-menu-wrapper` &tpl=`rss-menu-row` &orderBy=`editedon DESC, menuindex ASC, id ASC, pagetitle ASC` &filter=`template,6,2|template,8,2|id,8,2|id,7,2|id,3,2` ]]
Notes:
- any resources using templates 6 or 8 are excluded from the results. Resources with id of 7 or 3 are also excluded
the outer wrapper template chunk
<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel> <title>[[DocInfo? &docid=`1` &field=`longtitle`]]</title> <link>[(site_url)]</link> <description>[[DocInfo? &docid=`1` &field=`description`]]</description> <ttl>60</ttl> <copyright>copyright [(site_name)] [[CopyYears]]</copyright> <language>en-us</language> <atom:link href="[(site_url)][~88~]" rel="self" type="application/rss+xml" /> [+wrapper+] </channel> </rss>
Notes:
- the DocInfo snippet is used to retrieve data from the home page
- the CopyYears snippet is used to include the current year
- the 88 in
[(site_url)][~88~]
is the Resource ID of the rss page
the row template chunk
<item> <title>[[if? &is=`[+longtitle+]:empty` &then=`[+pagetitle+] - [(site_name)]` &else=`[+longtitle+] - [(site_name)]`]]</title> <link>[(site_url)][~[+id+]~]</link> <guid isPermaLink="false">[(site_url)][~[+id+]~]</guid> <pubDate>[+editedon:date=`%a, %e %b %Y %I:%M:%S %p %z`+]</pubDate> <description>[+description+]</description> </item>
Suggest an edit to this page.