Authors_index throwing error in server side rendering
dunxd opened this issue · 4 comments
In relation to #25 a function was added to JSON_Renderer.php to put authors into an array, so that they can be accessed by templates like this:
This works great client side/JavaScript
However, server side rendering throws an error:
Undefined constant "author_index" in $out =
Hmmm - this sounds familiar :-) See #11 (comment)
If you want to use the loop index, you need to call it "i" - and rename any outer loop indexes to something else...
Ok - I also recalled something but couldn't remember much before my holiday 😀
Can I clarify - the outer loop should have a named index (i.e. book_index
) and any iterations within that loop should use i
? What if there are multiple iterations inside? i.e. each book
contain multiple author
s, tag
s, custom column
s.
They can all use i
as the index as long as they don't contain any iterations?
Yep - as long as they loop on their own they can all use "i"
It's only with nested loops where you'll run into trouble if you want to use loop indexes for both at the same time - that the dirty hack for "i" in dot-php won't support, and I don't really want to add a "j", "k", ... in there either