1

Witch preprocess function let me add btn classes from bootstrap 3 to the two links at the bottom of every teaser in Drupal 7?

I tried the following.

function meetu_preprocess_node(&$variables) {
   $variables['content'] ['links']['node']['#links']['node-readmore']['attributes']['class']   
 [] = 'btn btn-primary'.
   $variables['content'] ['links']['node']['#links']['comment-add']['attributes']['class'][]   
  = 'btn btn-primary';
  }

The result is that my "add comment" link is gone and the "read more" link has its new classes.

What's wrong here?

Is this the right way to add bootstraps btn calsses to the two links named above?

closed as off-topic by kiamlaluno Aug 31 '14 at 2:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced, was solved by a cache clear, or was a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • To make it clear, this question has been closed because the code contains a typo, as shown from the given answer. We don't aim to teach PHP, nor would the question help future readers. – kiamlaluno Sep 3 '14 at 11:53
1

You were very close except at the end of your first line you had a "." instead of a ";".

function meetu_preprocess_node(&$variables) {
  $variables['content']['links']['node']['#links']['node-readmore']['attributes']['class'][] = 'btn btn-primary';
  $variables['content']['links']['node']['#links']['comment-add']['attributes']['class'][] = 'btn btn-primary';
}
  • This just hides the add comment link but do not add the second variable to the comment link button – Josh Sep 1 '14 at 19:34
  • Your comment is not clear. Can you ask again? – hargobind Sep 3 '14 at 10:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.