Keyword

K2 - Views - meta description bug

  • Adam Jakab
  • Adam Jakab's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 months ago #115959 by Adam Jakab
K2 - Views - meta description bug was created by Adam Jakab
using:
J!2.5.13
K2 2.6.7

If you have an item with content:
<p>ciaoàòòàòàòàààùàò</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>xxx</p>

and you inspect the document source in both <meta name="description"... and <meta property="og:description" you get this:
<meta property="og:description" content="ciaoàòòàòàòàààùàò � � xxx" />
<meta name="description" content="ciaoàòòàòàòàààùàò � � xxx" />

My template usese <meta charset="utf-8" /> so it's not about encoding but what happens is that the $metaDescItem variable (in com_k2/views/item/view.html.php but in other places as well) ~line:400
does:
$document->setDescription(K2_JVERSION == '15' ? $metaDescItem : html_entity_decode($metaDescItem));
and html_entity_decode causes this havoc.

Even when getting rid of the html_entity_decode in the code i still get:
<meta name="description" content="ciaoàòòàòàòàààùàò &amp;nbsp; &amp;nbsp; xxx" />

which would still produce rubbish in the meta description.

Adding something like:
$metaDescItem = str_replace("&nbsp;","", $metaDescItem);
just before setting the document description resolves the problem - but I do not want to do this every time I update K2, so this is really a bugfix request!

thanks
Adam

Please Log in or Create an account to join the conversation.

  • Francisco Javier Gonzalez Duque
  • Francisco Javier Gonzalez Duque's Avatar
  • Offline
  • New Member
More
10 years 10 months ago #115960 by Francisco Javier Gonzalez Duque
Replied by Francisco Javier Gonzalez Duque on topic Re: K2 - Views - meta description bug
The problem is with php. In php 5.4 all works fine.

For 5.3 or prior versions of php, you can use
php.net/manual/es/function.html-entity-decode.php

Regards

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum