Jump to content

Html Special Character on Fields


zeta1600

Recommended Posts

I have this code to pull the first few words from the body text to use as a title. But, when the body contains apostrophe, it shows on my title as '. I found the following code that's supposedly fixes the code. But, I can't figure out how. I need to add this:

$return = = htmlspecialchars_decode(token_replace($output, 'node', $node), ENT_QUOTES);

Or something similar ... to this:

$limit = 10;
$text = $node->body[$node->language][0]['value'];

$text = strip_tags($text);
      $words = str_word_count($text, 2);
      $pos = array_keys($words);
      if (count($words) > $limit) {
          $text = substr( $text, 0, $pos[$limit]);
          $text = trim( $text );
          $text = rtrim( $text, '.' );
          $text = trim( $text ) . '...';
      }

return  $text;

 

Thanks in advance.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.