Take advantage of Ditto's @FILE property

on 22-Sep-2009 | Comments ( 2 ) Tags: Evolution

Most of the times I use Ditto with custom templates and almost all the time my templates have one or more calls to other snippets. If your custom template sits inside a chunk then you probably know that you need to call Ditto uncached.

The following works only uncached:

<div>
    <h2><a href="[~[+id+]~]">[+pagetitle:htmlspecialchars+]</a></h2>
    <div>on [+date+] | Comments (  [[Jot? &docid=`[+id+]` &action=`count-comments`]]  ) For:  [[GetModxVersion? &ids=`[+modxVersion+]`]]</div>
    <div>[+introtext:htmlspecialchars+]</div>
</div>

with the following Ditto call:

[!Ditto? &parents=`10` &depth=`1` &tpl=`article` &showInMenuOnly=`1` !]

To overcome this caching limitation without creating another snippet you can use the @FILE property. First you would need to put the above template in a file on the server. For this example I've chosen the following path: 'assets/templates/site/chunks/article.html'

 

And here's the cached Ditto call:

[[Ditto? &parents=`10` &depth=`1` &tpl=`@FILE:assets/templates/site/chunks/article.html` &showInMenuOnly=`1`]]

If you know other Ditto tricks leave a message.

Write a comment

  • Required fields are marked with *.

If you have trouble reading the code, click on the code itself to generate a new random code.
 
mary
Posts: 1
Comment
Re: Take advantage of Ditto's @FILE property
Reply #2 on : Thu September 24, 2009, 09:41:39
Thanks for these tips!! I have added this site to the list of MODx resources at my blog - http://codingpad.maryspad.com/2009/04/13/modx-resources-and-tutorials-on-the-we/

You should add an About Me page :)
cipa
Posts: 1
Comment
cipa
Reply #1 on : Fri September 25, 2009, 10:28:29
I'm not sure an information about me is required. Maybe about the website. Or maybe I'll write something on the home page. But first I need more content :)

Quick modx Evolution Tags

  • cached [[snippet]] or uncached [!snippet!]
  • {{chunk}}
  • [+placeholder+]
  • [*resourceField/TV*]
  • [^timing^]
  • [~link~]

Quick modx Revolution Tags

  • cached [[snippet]] or uncached [[!snippet]]
  • cached [[$chunk]] or uncached [[!$chunk]]
  • [[+placeholder]]
  • cached [[*resourceField/TV]] or uncached [[!*resourceField/TV]]
  • no timing tag - must investigate
  • [[~link]]
  • [[++systemSetting]]
  • [[%languageStringKey]]
© modxRULES! 2009-2010