Score:0

['#attributes']['class'] variable is not being rendered on the page

do flag

I'm working on an old Drupal 7 site.

In the template file paragraphs-item--user-block-paragraph.tpl.php the content is being rendered, but the class is not added to the element.

Here is the code:

$content['#attributes']['class'][] = 'my-class';
print "<script>alert('".$content['#attributes']['class'][0]."');</script>"; // confirmed variable is set to my-class
print render($content); // confirmed correct file name

What variable in $content determines the classes of the element?

Score:0
cn flag

I don't know the structure of the template but it should be something like this:

$content['field'][0]['#attributes']['class'][] = 'my-class';

or

$content['field']['#attributes']['class'][] = 'your-class';
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.