1

I loaded a renderable array within a hook_block_view. I need to add a prefix and suffix to the title before rendering it. How can I manage to do that ?

  • are we talking about nodes or blocks here? – Jimajamma Jun 12 '13 at 18:34
  • well, i'm displaying nodes into a block and I need to add classes to their title – user2369093 Jun 13 '13 at 7:19
1

You have an error in the very title. Adding prefixes and suffixes is not a job for a module. You do it in template. If you need to wrap it in html tags, do it in node.tpl.php. If you need some more elaborated logic, see template_preprocess_node().

| improve this answer | |
  • I understand but when looking at the available variables in node.tpl.php we can find $title_prefix and $title_suffix that are supposed to be populated by modules. How can I popolate it ? – user2369093 Jun 12 '13 at 15:12
1

In hook_preprocess_node($variables) set $variables['title_prefix'] = 'test';

| improve this answer | |
0

locate the title in question, and add the prefix and suffix as you do in a form like this:

$array['the_title']['#prefix'] = "<div class='wrapper'>";
$array['the_title']['#suffix'] = "</div>";

Hope it helps

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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