Overcome caching limitation when you call a snippet inside another snippet

on 14-Sep-2009 | Comments ( 1 ) Tags: Evolution

Uncached snippets might put a big load on you server. To solve this problem we'll have to create a new snippet and make use of runSnippet() API.

$parentparent = $modx->runSnippet("ParentParent");
$wayfinderOutput = $modx->runSnippet("Wayfinder", array('startId' => $parentparent));
return $wayfinderOutput;

Because Wayfinder does not know how to get the second level parent ID of the current document, I had to create my own snippet: ParentParent. You can download this snippet here.

For readability sake, I saved the output of the ParentParent into a variable and then used it in the Wayfider call.

Not so hard! Leave a message if you know other solutions.

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
Reply #1 on : Mon September 14, 2009, 17:47:38
Nice one! Typo in the title - "cashing" should be "caching"


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