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:

    <h2><a href="[~[+id+]~]">[+pagetitle:htmlspecialchars+]</a></h2>
    <div>on [+date+] | Comments (  [[Jot? &docid=`[+id+]` &action=`count-comments`]]  ) For:  [[GetModxVersion? &ids=`[+modxVersion+]`]]</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.
Posts: 1
Re: Take advantage of Ditto's @FILE property
Reply #2 on : Thu September 24, 2009, 08: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 :)
Posts: 1
Reply #1 on : Fri September 25, 2009, 09: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

  • [[snippet]]
  • [[$chunk]]
  • [[+placeholder]]
  • [[*resourceField/TV]]
  • [[~link]]
  • [^timing^]
  • [[++systemSetting]]
  • [[%languageStringKey]]
  • all tags can be called un-cached like: [[! snippet]]

Timing Tags (Evo and Revo)

  • [^qt^] - Query time
  • [^q^] - Query count
  • [^p^] - Parse time
  • [^t^] - Total time
  • [^s^] - Source
© modxRULES! 2009-2014