I am using drupal advanced forum, due to migration from phpbb to D7 forum I noticed there are some HTML entities shown in my forum topic. I need to handle this in the tpl file. Can you please let me know where to implement it.

Screen shot special characters

  • Maybe it's not a template thing. When you edit the forum node/topic (ex: /node/4/edit) does the node title have & in it? – No Sssweat May 16 '16 at 10:56
  • Yes, It has the & in the reply. – Suneel Kumar P May 16 '16 at 11:09

This sounds like data transformation problem; the import didn't format the HTML entity title data on import. Instead of trying to code around the problem in your template, you should reformat your node titles.

Run a code snippet (e.g. drush scr myscript.php) that can fix the formatting on your nodes. Something like:

// @TODO: Retrieve your list of imported node nids in the $nids array
$nids = array(4, 5); 
foreach ($nids as $nid) {
  $node = node_load($nid);
  $node->title = html_entity_decode($node->title);
| improve this answer | |
  • Thanks Shawn. Will try the code. Also, can you let me know if i need to try formatting in the tpl file where should i do. I found advanced-forum-topic-list-view.tpl.php is used for display. But i am not sure where to format the title. Please suggest. – Suneel Kumar P May 17 '16 at 8:11
  • I've not used that module so I don't know. I'll reiterate this is a data transformation problem and not a display problem. Hacking the template to do the transformation for you is a bad idea. If you're set on doing this in the theme layer, you should do it in a template_preprocess_node() invocation. – Shawn Conn May 17 '16 at 15:12

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.