We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4673
    • 577 Posts
    Ok, I was wondering (I may have missed it though) what is the order of precedence for:
    snippets, chunks, TVs?
    Also, within a TV itself what would be the precedence here?

    I’m asking this because I’ve been playing a bit with TVs and noticed that these sort of slide together at times.
    It’s hard for me to explain because I was cutting/pasting/deleting/adding like mad a bit earlier.

    This is also to Susan’s cookie based language code. I noticed that I can’t call a TV that is using a chunk that is using a TV.
    hmmmm ...

    Maybe this should be a TSC (TV, snippet, chunk) rules for calling what from what but not in a what !?!?!

    Am I making any sense? (please no silly remarks that I’m not because I know I’m not but I’m trying tongue )

    I’m also asking since I saw a couple times in posts that certain code works as a snippet but not as a TV.

    oh well, I need to get some sleep!
      Tangent-Warrior smiley
      • 10487 MODX Staff
      • 1,535 Posts
      Hi Carsten,

      This is something I looked at recently, it’s difficult to give a straight answer to the order of precedence because the document parser runs through a number of cycles for a document. But, on each cycle, the document parser deals with them in this order:

      1. Template Variables and Document Variables
      2. Settings (eg. [(site_url)])
      3. Chunks
      4. Snippets
      5. Placeholders

      All of the above are parsed in the parseDocumentSource() in document.parser.class.inc.php.

      What I can’t wait for is the recursive parser in MODx 1.0 grin I think that will solve the majority of issues in this area.

      Hope that helps,

      Garry
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 4673
        • 577 Posts
        Yes, it does!
        Thanks!
          Tangent-Warrior smiley