We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45766
    • 78 Posts
    designmich.de Reply #1, 9 years ago
    Hi,

    here is a general question about the rendering-logic of modx.

    What does modx do if a have a template an chunk like this. Will MODx render all chunks even though the if doesn't match?
    and is there a difference between calling a chunk and a snippet like getCache?

    Template
    [[- <!-- home -->]]
    [[*template:is=`6`:then=`
    	[[!getCache?
    		&elementClass=`modChunk`
    		&element=`cache-homeTpl`
    		
    		&cacheExpires=`3600`
    	]]
    `]]
    
    [[- <!-- default -->]]
    [[*template:is=`1`:then=`
    	[[!getCache?
    		&elementClass=`modChunk`
    		&element=`cache-detailsDefault`
    		
    		&cacheExpires=`0`
    	]]
    `]]
    


    Chunk
    [[*hideCatTeaser:is=`hideCatTeaser`:then=``:else=`
    	<aside class="contentSection csw-75 containsBigTeaser sideBySide hideMobile">
    		
    		<h5>[[%i18n.teaser_context_headline? &language=`[[++cultureKey]]` &namespace=`i18ncustom`]]</h5>
    		
    		[[!getCache?
    			&elementClass=`modSnippet`
    			&element=`getResources`
    			&cacheExpires=`0`
    			
    			&parents=`[[*parent]]`
    			&context=`[[*context_key]]`
    			&resources=`-[[*id]]`
    			
    			&includeTVs=`1`
    			&includeContent=`0`
    			&depth=`0`
    			
    			&sortby=`{"publishedon":"DESC"}`
    			&showHidden=`1`
    			&limit=`2`
    			&tpl=`bigTeaser`
    		]]
    	</aside>
    `]]
    


    What if template is 6?
    Will cache-homeTpl be rendered even though its not matching?
    And what if cache-homeTpl contains more chunks, will they be rendered too?

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      These excellent blog posts of Mark Hamstra's may help, especially the second one:

      https://www.markhamstra.com/modx/2011/10/caching-guidelines-for-modx-revolution/

      https://www.markhamstra.com/modx/2011/11/nested-caching-in-modx-revolution/

      When you reach a certain point of nesting, though, you often have to just test it to see what will happen.

      When things reach that point, I usually put all the logic into a single custom snippet. It's much faster than using conditional output modifiers and I know for sure what will happen.

      You can see my thoughts on nesting here: https://bobsguides.com/blog.html/2014/05/15/dont-be-a-nester/.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 45766
        • 78 Posts
        designmich.de Reply #3, 9 years ago
        thanks! Exactly what i was lokoking for!

        BUT this means i produced a lot of overhead with my actual code - have to fix it - lot of work wink
          • 3749
          • 24,544 Posts
          The output modifiers were meant to provide convenient solutions for people who can't write PHP code, or want a quick way to control the format of their output.

          If everything is cached, the overhead is not as serious, but when you introduce conditional output modifiers, caching tends to go out the window. wink

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 45766
            • 78 Posts
            jep…for small projects ok. But i habe some big ones where the first page call takes some time. maybe because there are a lot of chunks rendered which are not needed - but i am getting better and better with modx wink