We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15001
    • 697 Posts
    (...)
    Is there some limit to the snippet call nesting ?

    For the first time, I’m trying to nest 3 snippet calls and cannot get it work.

    My first snippet call is [!LoadDocument!], which allows me to load the content of a document from a text file.
    In this file is a [[Ditto &tpl=`my_chunk` ]] call and in the template chunk for Ditto contains this code :
    <img src=`[!GetField? &docid=`29` &field=`image1` !]` />
    (...)
    After experimenting, I found out that nesting more than 2 levels for snippets is possible.

    If the first snippet is called in uncachable mode [!...!], then the sublevels must be called in cachable mode.
    This means not inverting bracket types for odd/even levels, but only after the 1st level.

    In above example, I could solve the problem by calling GetField in cached mode [[...]], although it was itself called from the template specified to format the output of a cached Ditto call.

    Hope that this can help others.
      • 24000
      • 1 Posts
      None of the search results seem to help, and even the examples I found don’t seem to work.

      A few examples:

      ++++
      [!Wayfinder? &startId=`[[UltimateParent]]`!]
      ++++
      [!sanitise_string? &dirtyString=`[[UltimateParent]]`!]
      ---------
      [!sanitise_string? &dirtyString=`[[Wayfinder? &startId=`49` &titleOfLinks=`id` &textOfLinks=`pagetitle`]]`!]
      __________
      [!sanitise_string? &dirtyString=`cheese noodle madness`!]


      returns

      ++++
      <ul><li class="active"><a href="/mtn/--2009-03-11/index.php?id=51" title="General Information" >General Info</a><ul><li class="active"><a href="/mtn/--2009-03-11/index.php?id=61" title="Admission Information" >Admission Information</a></li> <li class="last"><a href="/mtn/--2009-03-11/index.php?id=62" title="Maps & Directions" >Maps & Directions</a></li> </ul></li> <li><a href="/mtn/--2009-03-11/index.php?id=52" title="Education" >Education</a></li> <li><a href="/mtn/--2009-03-11/index.php?id=53" title="Exhibits" >Exhibits</a></li> <li><a href="/mtn/--2009-03-11/index.php?id=54" title="What’s On" >What’s On</a></li> <li><a href="/mtn/--2009-03-11/index.php?id=55" title="In the News" >News</a></li> <li><a href="/mtn/--2009-03-11/index.php?id=56" title="Become a Supporter" >Support</a></li> <li class="last"><a href="/mtn/--2009-03-11/index.php?id=57" title="WCED Mobile ScienCentre" >WCED Mobile</a></li> </ul>
      ++++
      50|hello
      ---------
      [[sanitise_string? &dirtyString=`<ul><li><a href="http://localhost/mtn/--2009-03-11/" title="1" >Home</a></li> <li><a href="/mtn/--2009-03-11/index.php?id=47" title="47" >About</a></li> <li class="last"><a href="/mtn/--2009-03-11/index.php?id=6" title="6" >Contact</a></li> </ul>`]]
      __________
      cheese noodle madness|hello



      All sanitise_string does for now is append |hello to $dirtyString

      Notice the 2nd last example, outer snippet didn’t get parsed, but [! !] changed to [[ ]]

      Any ideas?



        • 25483
        • 741 Posts
        I don’t know if it is possible to call a snippet with details inside another.

        Can you tell us what you want to do? Why do you need to call a snippet inside a snippet?
          with regards,

          Ronald Lokers
          'Front-end developer' @ h2o Media