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
[ed. note: nondotzero last edited this post 13 years, 6 months ago.]