We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16899
    • 284 Posts
    Hi guys

    I´m trying a solution to avoid some extra templates... so my idea is use a solution to switch chunks on folder name detenction.

    In my case i´ll have 3 diferents page header, a default one and the other two for to sub brands.

    What i want is, using the same template, when i´m inside on the sub brand folder use his own page header chunk, the same for the second one, if i´m not inside of these subbrands folders, then i´ll use the default page header chunk.

    I was having a look on the If addon, but i´m not sure how to work with it on thissolution!!!

    Any ideas?

    Regards, Nuno

    P.S sorry about my english.
      • 16899
      • 284 Posts
      Hi guys, any ideas about this subject? sad
        • 30912
        • 463 Posts
        What do you mean by folder?

        and you might be better looking at AndIf (https://forums.modx.com/thread/32601/andif---conditional-snippet-allowing-multiple-and-or-conditions)

        We use it on a site or two to say

        If subject matches a, b or c then do thise else do something else.

        Hope that helps
          • 16899
          • 284 Posts
          Quote from: Tyreal2012 at Mar 01, 2013, 08:19 AM
          What do you mean by folder?

          and you might be better looking at AndIf (https://forums.modx.com/thread/32601/andif---conditional-snippet-allowing-multiple-and-or-conditions)

          We use it on a site or two to say

          If subject matches a, b or c then do thise else do something else.

          Hope that helps

          Alrightttttt is something like this that i need!!!! Ok, i need a situation like isFolder x then use ChunkA, isfolder Y then use ChunkB, else use Default Chunk!

          How can i do this with And IF??
            • 30912
            • 463 Posts
            Im not saying its the right way but we have this:

            [[AndIf? &condition=`[[*id]] is 64|[[*id]] is 97|[[*id]] is 98|[[*id]] is 99|[[*id]] is 100` &operator=`OR` &then=`
            <div class="mat-box">
              <div class="mat-box-top"><img src="images/mat-box-top.jpg" width="345" height="11" /></div>
              <div class="mat-box-title">Types of Materials</div>
              <div class="mat-box-cont">
                <ul>
                 [[getResources? &parents=`64` &limit=`15` &tpl=`Mat_List` &sortby=`menuindex` &sortdir=`ASC`]]
                </ul>
                <div class="clear"></div>
              </div>
              <div class="clear"></div>
              <div class="mat-box-bottom"><img src="images/mat-box-bottom.jpg" width="345" height="17" /></div>
            </div>`
            
            &else=``]]
            
            [[AndIf? &condition=`[[*id]] is 65|[[*id]] is 101|[[*id]] is 102|[[*id]] is 103` &operator=`OR` &then=`
            <div class="mat-box">
              <div class="mat-box-top"><img src="images/mat-box-top.jpg" width="345" height="11" /></div>
              <div class="mat-box-title">Types of Materials</div>
              <div class="mat-box-cont">
                <ul>
                 [[getResources? &parents=`65` &limit=`15` &tpl=`Mat_List` &sortby=`menuindex` &sortdir=`ASC`]]
                </ul>
                <div class="clear"></div>
              </div>
              <div class="clear"></div>
              <div class="mat-box-bottom"><img src="images/mat-box-bottom.jpg" width="345" height="17" /></div>
            </div>`
            
            &else=``]]
            


            The first bit says if id is equal to either 67,97 etc then display the code, if it isnt dispaly nothing (to which you would add the default content) the second call says if it is 65, 101 etc then display the content else display nothing.

            NOTE the pipes | between each condition.

            There are other ways to do it however this is the one I have used.

            You could also use Switch if its a very binary output

            http://modx.com/extras/package/switch

            [[!switch?  &get=`[[*id]]`    &c1=`1` &do1=`CHUNK_A`    &c2=`2` &do2=`CHUNK_B`      &default=`Default_Chunk`  ]]   


            I re read your question and if there is only two options the use Switch, else try AndIf
              • 4172
              • 5,888 Posts
              can't you just use the parent-id to create the chunk-names?

              [[$myChunk_[[*parent]]]]


              and have chunk-names like:

              myChunk_0
              myChunk_1
              myChunk_2
              myChunk_3

              when having a page-structure like that:

              -folder A (1)
              --subfolder AA
              --subfolder AB
              -folder B (2)
              --subfolder BA
              --subfolder BB
              -folder C (3)
              --subfolder CA
              --subfolder CB
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 16899
                • 284 Posts
                Quote from: Bruno17 at Mar 01, 2013, 09:10 AM
                can't you just use the parent-id to create the chunk-names?

                [[$myChunk_[[*parent]]]]


                and have chunk-names like:

                myChunk_0
                myChunk_1
                myChunk_2
                myChunk_3

                when having a page-structure like that:

                -folder A (1)
                --subfolder AA
                --subfolder AB
                -folder B (2)
                --subfolder BA
                --subfolder BB
                -folder C (3)
                --subfolder CA
                --subfolder CB

                Yes... this is a good idea!!! Really clever in fact!!! smiley I´ll have to try it!! Many thanks!!!!
                  • 16899
                  • 284 Posts
                  Hey Tyreal2012

                  Also good sugestions... i guess i´ll have a look on the switch plugin!!! Thanks a lot! smiley