We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    Normally we would insert snippets, TVs, placeholders, and site variables into a template document using [[]], [**],[++] or [()] respectively.

    Cacheable Syntax:

    [[Snippet]]
    
    [+Placeholder+]
    
    [(SiteVariable)]
    
    [*TemplateVariable*]


    The above elemnts are rendered as html and saved whenever the document is marked as "Cacheable".

    We can however execute the above elements inside a cached document by replacing the first bracket ("[") symbol of the syntax shown above with "[ @] " symbol (removing spaces). This will cause the parser to treat such elements as "Active Elements" (non-cached elements) and will render or execute them even when the document is cached. This works similar to non-cached snippets [!!] but is designed to work with other resource elements inside the template:

    Non-Cacheable Syntax:

    [@][Snippet]]
    
    [@]+Placeholder+]
    
    [@](SiteVariable)]
    
    [@]*TemplateVariable*]


    With this syntax snippets, tvs, etc found inside a cached document will be able to function as they normally would if the document was not cached. This means that the $modx->documentObject will be available to snippets at all times without having to retrieve the document information from the database.

    Another side feature is that you can also have secured cached-documents. This means that a web document does not have to be dynamic in order to be secure. Secured cached-documents will only be available to web users that have access to those pages cached pages.

    One disadvantage to this design is that there will be an increase in cached file of the document. Process these new cached documents will be "slightly" slower (in micro-seconds) than the current design used.


    What do you think? Should we implement these design?
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 25663 MODX Staff
      • 12,272 Posts
      This is a great idea, but I’m not so sure about the syntax. A minute performance hit in my mind is outweighed by the increased flexibility.

      What do you think about replacing the opening/closing brackets with braces to denote non-cacheable object as an alternate syntax, like:
      {[Snippet]}
      
      {+Placeholder+}
      
      {(SiteVariable)}
      
      {*TemplateVariable*}


        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 32963
        • 1,732 Posts
        Quote from: rthrash at Jul 11, 2005, 01:01 AM

        This is a great idea, but I’m not so sure about the syntax. A minute performance hit in my mind is outweighed by the increased flexibility.

        What do you think about replacing the opening/closing brackets with braces to denote non-cacheable object as an alternate syntax, like:
        {[Snippet]}
        
        {+Placeholder+}
        
        {(SiteVariable)}
        
        {*TemplateVariable*}




        the problem here is that there is no unique symbol to look for before parseing the document. Currently the unique symbol for non-cache snippet is [!. How there parser works is that if it see a [! the document it will convert it to a [[ and then parse the document.

        If we where to use { then we should have to look for {+, {[, {( or just { which is commonly used. That would have a greater performance hit
          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.
          • 25663 MODX Staff
          • 12,272 Posts
          Other ideas then will be required... hmmm...

          Perhaps we should go to a single openning code/snippet/chunk indicator and then put another indicator inside:

          cacheable:
          [[snip:SnippetName]]
          [[chunk:ChunkName]]
          [[tempvar:TVName]]
          [[place:PlaceholderName]]

          non-cacheable:
          [!snip:SnippetName!]
          [!chunk:ChunkName!]
          [!tv:TVName!]
          [!phold:PlaceholderName!]


          or something along those lines... then the parser would only be looking for two instances [[ and [!, and if found determining how to parse the requisite parts... right?
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me