Keyword

k2 page titles configure

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 3 weeks 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.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 5 months ago - 7 years 5 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: 7 years 5 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
7 years 5 months ago - 7 years 5 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: 7 years 5 months ago by Ronny Van Der Borght. Reason: Typo

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 months ago #165357 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
Thank you Ronny :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 5 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.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 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

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 5 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.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 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.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 5 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.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #165559 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
Can you send me a link please?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 4 months ago - 7 years 4 months ago #165567 by burnyourears
Replied by burnyourears on topic k2 page titles configure
That is the actual setting for the individual Page-Titel-Tag (which I somehow tried to integrate wit the "$safemeta;"-Code above – and failed)
<?php
$newtitle= ($this->item->title . ' | Review');
$document = JFactory::getDocument();
$document->setTitle($newtitle);
?>

When I delete that part of the code, everything is fine and "Spock's Beard" looks fine as it should. So it must have something to do with the posted snippet ...
Last edit: 7 years 4 months ago by burnyourears. Reason: Deleting a link to the page.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #165575 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
Try this instead.
$safe 		= array("", "");
$nonsafe 	= array("'", "\"");
$safemeta 	= str_replace( $nonsafe, $safe, $this->item->title);
$newtitle   = (' Review: ' . $safemeta . ' | ' . $this->item->category->name);
$document   = JFactory::getDocument();
$document->setTitle($newtitle);

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 4 months ago - 7 years 4 months ago #165579 by burnyourears
Replied by burnyourears on topic k2 page titles configure
Thank you, but it does not help or change anything (just relocated the "review" in the code, but it should not have an impact because your version does not work either ...).

That's the code I use:
<?php
$safe 		= array("", "");
$nonsafe 	= array("'", "\"");
$safemeta 	= str_replace( $nonsafe, $safe, $this->item->title);
$newtitle   = ($safemeta . ' | Review - XXX');
$document   = JFactory::getDocument();
$document->setTitle($newtitle);
?>

Any further idea? :/
Last edit: 7 years 4 months ago by burnyourears.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #165605 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
What does this produce in your override?
<?php
$safe 		= array("", "", "", "");
$nonsafe 	= array("'", "\"", "", "#039;", "&amp;");
$safemeta 	= str_replace( $nonsafe, $safe, $this->item->title);
echo $safemeta; 
?>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 4 months ago - 7 years 4 months ago #165610 by burnyourears
Replied by burnyourears on topic k2 page titles configure
Ahhh, thank you! Better ... now it's "Spock&s Beard" instead of "Spock's Beard", bute we're getting to the core ;-)

One last idea?

That's the code right now:
<?php
$safe 		= array("", "", "", "");
$nonsafe 	= array("'", "\"", "", "#039;", "&amp;");
$safemeta 	= str_replace( $nonsafe, $safe, $this->item->title);
$newtitle   = ($safemeta . ' | Review - XXX');
$document   = JFactory::getDocument();
$document->setTitle($newtitle);
?>
Last edit: 7 years 4 months ago by burnyourears.

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

More
7 years 4 months ago - 7 years 4 months ago #165611 by burnyourears
Replied by burnyourears on topic k2 page titles configure
Ok, I experimented a bit with your code and now I have it:
<?php
$safe 		= array("'");
$nonsafe 	= array("&#039;");
$safemeta 	= str_replace( $nonsafe, $safe, $this->item->title);
$newtitle   = ($safemeta . ' | Review - XXX');
$document   = JFactory::getDocument();
$document->setTitle($newtitle);
?>

So your ideas lead to that point I could make it – thank you very much! :D
Last edit: 7 years 4 months ago by burnyourears.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #165621 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
You 're welcome, and I'm glad I could assist you :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
4 years 3 months ago - 4 years 3 months ago #177912 by Wilfried
Replied by Wilfried on topic k2 page titles configure
<?php
$newtitle= $this->item->extraFields->EXTRAFIELDALIASHERE->value;
$document = JFactory::getDocument();
$document->setTitle($newtitle);
?>
Hi,
I used this solution to add the tag <title> to each page of my website. The result is ok, but the extrafield is visible in frontend. Is it possible to hide the extrafield in the frontend and only have the option in the backend?

Example: the word "Test" appear in the navigator and the extrafield "Balise title:" is visible before the video.
www.cryptoseries.fr/series/item/445-huff

Sorry for my english, I am french.
Last edit: 4 years 3 months ago by Wilfried.

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

More
4 years 3 months ago #177916 by Wilfried
Replied by Wilfried on topic k2 page titles configure
If anybody have an idea? I can add explanation or maybe provide more examples?
Thanks

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

More
4 years 2 months ago #177931 by JoomlaWorks
Replied by JoomlaWorks on topic k2 page titles configure
Create an override (if you haven't done so already) and remove the extra fields loop. If you choose to hide extra fields in the options of the category they may not render at all (if I recall correctly).

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum