I wanted to insert a related-articles block after the n-th content element using stash. But it seems Content Elements doesn't provide a {count}
variable in the elements loop.
1 Answer
I've added a {ce_counter}
variable to the elements loop.
Open the ft.content_elements.php
file and navigate to the replace_tag
function.
Insert $i_counter = 0;
just before the foreach $data
loop.
In the loop, look for the // Counter
section and add:
$i_counter++;
$tagdata_parsed = str_replace('{ce_counter}', $i_counter, $tagdata_parsed);
In the loop, look for the // Parse varibles in conditions
sections and add 'ce_counter' => (int) $i_counter
as an extra array item.
Now you can use {ce_counter}
as a variable in the loop.