Thanks to all your replies.... i found a nice solution.
I purpose is to have different ditto template depending the website tempalte used on the page contaning the Ditto Call.
In this way it should be easy to move between template. Because, of course, when you change your website template you must often also make change in the different ditto template and other ’chunk template’.
With the ditto example, we can see that more generally it is all the webpage that is calling ditto that must be impacted: in this page you are calling Ditto and you are also using placeholders as [+page+], [+next+] and maybe also have Reflect call, as in the default example web site. So it is all this document which is very bind to the template used (davidm says the same thing in this post).
So, the better is to take all these call of this page and to put theses lines in a Chunk.
Take the default website as example
The ditto webpage is this one:
[[Ditto? &startID=`2` &summarize=`2` &removeChunk=`Comments` &tpl=`ditto_blog` &paginate=`1` &extenders=`summary,dateFilter` &paginateAlwaysShowLinks=`1` &tagData=`documentTags`]]
Showing [+start+] - [+stop+] of [+total+] Articles
[+previous+] [+pages+] [+next+]
[[Reflect? &dittoSnippetParameters=`startID:2` &groupByYears=`0` &showItems=0` &tplMonth=`reflect_month_tpl`]]
Ok
just cut these lines and put this Chunk call in the document:
Now
Create the chunk DittoCall and copy the cutted line inside.
Yes, if we make a test now, all is as before. We are just calling a chunk that contains the lines which was in the document before.
Now
create a new asset, called GetTemplateChunk:
<?php
global $table_prefix;
/* Get parameter Value */
$chunk = isset($chunk) ? $chunk : "";
$output = "";
if ($chunk != "")
{
$templateId = $modx->documentObject['template'];
$templateName =
$modx->db->getValue($modx->db->select("templatename", $table_prefix."site_templates", "id='$templateId'"));
$output = $modx->getChunk($chunk."_".$templateName);
if ($output == "")
{
$output = $modx->getChunk($chunk."_default");
}
}
return $output;
?>
This one is used to get a chunk that is website template dependant. The param is chunk.
The asset will return the content of the chunk with the following name: ’paramChunk’_’templateName’.
If this one does’nt exist it will return the content of the following chunk: ’paramChunk’_default.
Ok come back to our example.
Open the last created chunk ’DittoCall’ and Duplicate it with the following name: ’DittoCall_default’
Now in the Chunk ’DittoCall’ put only this line:
[[GetTemplateChunk? &chunk=`DittoCall`]]
This call will return the content of the chunk named DittoCall_’templateName’ or DittoCall_default if not exist.
So if you make a test in this state, it is the DittoCall_default that will be return... All is as before.
Now, when creating a new website template, just put this new Template ’my_template’ as the default one for all your Document. (the Document contening the {{DittoCall}} line will have this new template as template).
Create a new Chunk "DittoCall_my_template". To customise All the Ditto page with the newTemplate.
Now test, yes, this it is this new Chunk that is used to renderer your document.
==> Now when you change your template, you don’t need to modify all your important document (i.e. top folder document , often bind to templates). And you don’t loose all your parameter used with the website template used before. It is really smart and easy.
---------------------
www.fabienletort.com