2

Node title includes ' (apostrophe) and it appears normal while viewing the node. But in page source it appears as '.

And for the same reason when I want to share this node on Twitter with some custom code put into node.tpl.php (<?php print urlencode($title) ?>) it also shows the ' as &#039;.

How to solve this problem?

  • 1
    I think you want to say "appears" (or "is shown as") instead of "seems", no? – Pierre.Vriens Aug 11 '16 at 11:24
2

Your issue seems similar to what's written in issues such as this or this.

The solution appears to be to use decode_entities, e.g. something like this:

$node->title = decode_entities($node->title);
  • Thanks for the answer. I'm printing the titles with <?php print $title; ?> on node.tpl.php. I tried print decode_entities($title); but this didn't work. Where should I use this? – herci Aug 11 '16 at 11:32
  • 2
    Bizarre (strange)! I thought your issue looked similar to what I wrote in this answer. So give me some more time to further think about this. While waiting, a (maybe silly) extra thought: could it be a cache issue why it didn't work "yet"? – Pierre.Vriens Aug 11 '16 at 12:07
  • Immm, sorry it works now :) I misused the code. Thanks. – herci Aug 11 '16 at 12:30
  • 2
    Aha, so I was right about my "bizarre" (strange) ALSO ... thank you for confirming ... and the "accept" of course! Next question?!?!?! – Pierre.Vriens Aug 11 '16 at 12:34
0

I had the same issue. I was using a Token to capture my field and send it to Twitter. I solved it by changing which Token format I was using.

For example:

Use

[node:field-twitter-message]

Instead of

[node:field_twitter_message]

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.