I’m using MODx 0.9.6 with Ditto version 2.0.2 and PHx version 2.1.2
Here’s what I’m trying to accomplish. I’m trying to make it so that on a site I can modify the TPL’s for the ditto. So depending on the children of the parent, there will be a different output in the TPL that ditto uses. In my case, I’ve got a page that has endorsements for a Congressional Candidate. Some endorsements will include pictures, others will not. So I’m trying to make it so that if the endorsement doesn’t have an image, a different TPL will be used. Here’s the logic I’m using:
Here is the ditto call of the parent:
[[Ditto? &startID=`55` &tpl=`endorsementTPL` &summarize=`50` &sortDir=`DESC` &sortBy=`pub_date` &depth=`1` ]]
But as I mentioned above, some endorsements don’t have a picture. So I created a chunk named "endorsementTPL" with the following code:
[+endorsementswitch:is=`0`:then=`{{endorsementpicNOTPL}}`:else=`{{endorsementpicTPL}}`+]
As you can see I’m using PHx to try and modify which TPL will be chosen. The customer choses in the document’s T.V. whether there is an endorsement or not. If so, they get "{{endorsementpicTPL}}" which has:
<div id="endorsementsbox">
<img id="endorsementsboximg" src="[+endorsementimg+]" alt="Mike Lumpkin Endorsement" />
<div id="endorsementstext">
<textile>
[+introtext+] <a href="[+id+]">read more</a>...
</textile>
<div id="endorsementsname">
<p>[+longtitle+]</p>
</div><!--Endorsments Name-->
</div><!--Endorsements Text-->
</div><!--Endorsements Box-->
If no picture, they choose "{{endorsementpicNOTPL}}" which has:
<div id="endorsementsboxnoPic">
<div id="endorsementstextnoPic">
<textile>
[+introtext+] <a href="[+id+]">read more</a>...
</textile>
<div id="endorsementsname">
<p>[+longtitle+]</p>
</div><!--Endorsments Name-->
</div><!--Endorsements Text-->
</div><!--Endorsements Box-->
Here’s the problem that I’m having.
On the parent document, there will be the output for that particular TPL (background images and such), but the values for the T.V.’s are not showing up. In other words, [+longtitle+], [+introtext+], [+endorsementimg+] are not producing an output. I’ve tried changing them to [*longtitle*], [*tvlongtitle*], [+tvlongtitle+] For example, the output for the endorsement box with a picture is shown here:
<div id="endorsementsbox">
<img id="endorsementsboximg" src="" alt="Mike Lumpkin Endorsement" />
<div id="endorsementstext">
<p> <a href="85">read more</a>...</p>
<div id="endorsementsname">
<p></p>
</div><!--Endorsments Name-->
</div><!--Endorsements Text-->
</div><!--Endorsements Box-->
Am I approaching this problem the wrong way? Is there an easier way to modify which TPL the ditto will use for a particular child document?
Any insight will be greatly appreciated...thanks!