Keyword

k2 page titles configure

More
3 years 10 months ago #161311 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
The site's name is added through your site's global configuration.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

More
3 years 3 months ago - 3 years 3 months ago #165350 by burnyourears
Replied by burnyourears on topic k2 page titles configure
Hi,

I use this code to place the article-title and the category in the page title. So far it's working:
<?php
$newtitle= (' Review: ' . $this->item->title . ' | ' . $this->item->category->name);
$document = JFactory::getDocument();
$document->setTitle($newtitle);
?>

My problem: When an article has the special character >> ' << , it shows the html-code in the page title instead: #039;

> For example, "Spock's Beard" is getting "Spock#039;s Beard" in the page title.

Any idea how I could fix that?

:-)
Last edit: 3 years 3 months ago by burnyourears.

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

  • Ronny Van Der Borght
  • Ronny Van Der Borght's Avatar
  • Offline
  • Senior Member
More
3 years 3 months ago - 3 years 3 months ago #165353 by Ronny Van Der Borght
Replied by Ronny Van Der Borght on topic k2 page titles configure
Thanks to Krikore (See also gist.github.com/kricore/2c9a5434748c5f5f6cf9)
$safe 		= array("", "");
$nonsafe 		= array("'", "\"");
$custometa 	 = $this->item->title;
$safemeta 	= str_replace( $nonsafe, $safe, $custometa);
echo $safemeta;
Last edit: 3 years 3 months ago by Ronny Van Der Borght. Reason: Typo

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

More
3 years 3 months ago #165357 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
Thank you Ronny :)

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

More
3 years 3 months ago #165456 by burnyourears
Replied by burnyourears on topic k2 page titles configure
Thank you!

Unfortunately I am no coder and need some help how to integrate this within my code ... Where do I have to put the " $safemeta;" ? Something like this (does not work ...) ?
<?php
$safe 		= array("", "");
$nonsafe 		= array("'", "\"");
$custometa 	 = $this->item->title;
$safemeta 	= str_replace( $nonsafe, $safe, $custometa);

$newtitle= (' Review: ' . $safemeta . ' | ' . $this->item->category->name);
$document = JFactory::getDocument();
$document->setTitle($newtitle);

?>

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

More
3 years 3 months ago #165464 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
You will need to add this to your item.php overrides.
Make sure to always use overrides :) getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

More
3 years 3 months ago #165476 by burnyourears
Replied by burnyourears on topic k2 page titles configure
Yep, for sure - I know :-)
But I don‘t know where in the code and how to merge with my codesnippet. Hmmm...

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

More
3 years 3 months ago #165490 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
You can place it pretty anywhere in the item.php file.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

More
3 years 3 months ago #165495 by burnyourears
Replied by burnyourears on topic k2 page titles configure
Sorry, I don't get it. I tried this:
<?php

$safe 		= array("", "");
$nonsafe 		= array("'", "\"");
$custometa 	 = (' Review: ' . $this->item->title . ' | ' . $this->item->category->name);

$newtitle= str_replace( $nonsafe, $safe, $custometa);
$document = JFactory::getDocument();
$document->setTitle($newtitle);

?>

But the ' still is in the title tag. What do I not understand?

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

More
3 years 3 months ago #165559 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
Can you send me a link please?

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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


Powered by Kunena Forum