We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21739
    • 49 Posts
    I'm using rowboat to retrieve a variable set of columns from a custom table (based on the current page, the retrieved columns differ):

    <table>
    [[Rowboat? 
    ....   
    &columns=`[[var-cols? &input=`[[*var-specs]]`]]` //-> a snippet is returning the correct value here
    .... 
    &where=`{"category[[*cat-level]]:=":[[*cat-id]]}`
    ]]
    </table>


    The above works perfectly
    The issue I'm having however, is creating a "variable" chunk for the tpl's structure, based on the required data.

    Since rowbot doesn't allow me to use @INLINE or @CODE, I have to use a chunk :
    <table>
    [[Rowboat?
    ...
    &tpl=`chunk-with-variable-structure`
    ...
    ]]
    </table>


    So, to accomplish a 'dynamic' chunk, I've placed a snippet inside the chunk to return the required columns:

    The tpl chunk "chunk-with-variable-structure":

    <tr> [[productTbl? &input=`[[*var-cols]]`]] </tr>  //-> var-cols contains  field1;field2;field3


    The snippet placed inside the chunk:
    $array = explode(";", $input);
    $result = '';
    foreach ($array as &$value){    
        $value = "<td>[[+spec_" .strtolower($value)."]]</td>";
        $result = $result . $value ;
    }
    return $result;


    The problem
    So far, this snippet does return the desired fields as required to the chunk for example: "<td>[[+spec_field1]]</td><td>[[+spec_field2]]</td>", however... the values from these "[[+fields]]'s" is the same for every returned row =(

    • Is caching causing this? Calling the snippet uncached didn't help.
    • Is the snippet parsing the [[+spec_field]]'s ? Can I make the snippet return a string in stead of the parsed fields?

    Since I'm a front-end dev I'm unable to create a custom snippet for the entire process, any help for a workaround to my current setup would be appreciated.

    Modx 2.2.7 / Rowboat 1.1.0

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

    [ed. note: nondotzero last edited this post 13 years, 6 months ago.]
    • discuss.answer
      • 38290
      • 712 Posts
      Try passing a unique value as a parameter into productTbl. Perhaps rowboat provides an integer to represent current row?
        jpdevries
        • 38290
        • 712 Posts
        Just peeked at the docs try using _idx
          jpdevries
          • 21739
          • 49 Posts
          I cannot believe it was this simple!
          Thanks jpdevries!
            • 38290
            • 712 Posts
            Glad that worked
              jpdevries