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?

  • 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.