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

    modx revo 2.5.2
    getresources 1.5.1
    localhost mamp 5.3.2
    if 1.1

    The scenario is I wish to use getresources to generate a list of boxes and the box size is determined through a template variable checkbox within my template.


    The getResources resides in the template and calls the 'item' chunk

    [[!getResources? 
    &tpl=`item`
         &limit=`100` 
        &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &parents=`4` &includeContent=`1` &showHidden=`1`  
    ]]   


    'item' chunk

    [[If? &subject=`[[+item_size]]` &operator=`EQ` &operand=`yes` &then=`[[$item-small]]`&else=`[[$item-large]]`]]
    


    "item_size" TV input type radio buttons - Input Option Values yes==yes||no==no

    item-small chunk -
    <div class=" item" style="">
        <div class="item-inside">
        <h3>[[+pagetitle]]</h3>
    
        </div>
      </div>

    item-large chunk
    <div class="item col2">
    <div class="item-inside">
        <h3>[[+pagetitle]]</h3>
        </div>
      </div>



    A list is generated and the radio button tv does determine the size of the box generated however the box [[+pagetitle]] always shows the first box name rather than the box it represents.

    Hope this is clear and anyone can help.

    Thanks in advance.


      • 22427
      • 793 Posts
      It might help to call the pagetitle field uncached:
      [[!+pagetitle]]
        • 22427
        • 793 Posts
        The use of the If snippet I always find a bit clumsy. Since your two item-chunks differ just in the first line, you could replace your chunk item by the following which uses output modifiers:
        <div [[+item_size:is=`yes`:then=`class=" item" style=""`:else=`class="item col2"`]]>
            <div class="item-inside">
            <h3>[[+pagetitle]]</h3>
            </div>
        </div>
        
        And so you need only this single chunk, not three. [ed. note: ottogal last edited this post 13 years, 10 months ago.]
          • 42124
          • 2 Posts
          ottogal,

          solution 2 sis the cracker I was after. I was definitely overcomplicating this. Thanks for the help.

          Just for the record I tested using an uncached pagetitle within the call and that did not work with the if statement.