- πΊπΈUnited States hcanning
Outstanding solution guys! Works great. Thanks
The paragraph.html.twig template file doesn't have the current loop index available to it, so we have no idea what item is currently being rendered - it is useful sometimes to know what the index is, as we might want to set some different css classes or similar on specific indexes.
To work around this, I added a field hook in my template:
function mytheme_preprocess_field(&$variables) {
if($variables['field_name'] == 'my_paragraph_field'){
foreach($variables['items'] as $idx => $item) {
$variables['items'][$idx]['content']['#paragraph']->index = $idx;
}
}
}
This enables me to access the index in the twig template using paragraph.index
, but it would be preferable if this or something similar was available natively.
Active
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Outstanding solution guys! Works great. Thanks