Keyword

Items Custom Meta Title

  • massimiliano
  • massimiliano's Avatar Topic Author
  • Offline
  • New Member
More
7 years 2 months ago #163773 by massimiliano
Items Custom Meta Title was created by massimiliano
Hello,
can someone explain me how manage Items Meta Title?
I want to have the possibility to customize meta title for single item. Now the meta title is the Item title.
But i would like to change for some items.

Thanks

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #163779 by Krikor Boghossian
Replied by Krikor Boghossian on topic Items Custom Meta Title
You can use an extrafield in your overrides (item.php) as a custom meta tag.
A starting point can be found here:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L176-L191

More on overrides can be found here:
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.

  • massimiliano
  • massimiliano's Avatar Topic Author
  • Offline
  • New Member
More
7 years 2 months ago #163866 by massimiliano
Replied by massimiliano on topic Items Custom Meta Title
HI,
thanks for answer.
I added this code on my item.php file template:
...................................
<?php
$doc = JFactory::getDocument();
if ( isset( $this->item->extraFields->title_tag->value ) && ($this->item->extraFields->title_tag->value !=='') ) {
$doc->addCustomTag('<title>'.$this->item->extraFields->title_tag->value.'</title>');
}
if ( isset( $this->item->extraFields->meta_description->value ) && ($this->item->extraFields->meta_description->value !=='') ) {
$doc->addCustomTag('<meta name="description" content="'.$this->item->extraFields->meta_description->value.'" />');
}
// See also gist.github.com/kricore/2c9a5434748c5f5f6cf9
// Cleanup the extrafields content so you can use them as metatags
$safe = array("", "");
$nonsafe = array("'", "\"");
$custometa = $this->item->extraFields->NAME->value;
$safemeta = str_replace( $nonsafe, $safe, $custometa);
echo $safemeta;
?>
..................................................
After i created an extrafield called Meta title, but i don't undertsand where i have to put the extrafield name.
Can you explain me what i have to do please?

Thank you very mutch

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #163893 by Krikor Boghossian
Replied by Krikor Boghossian on topic Items Custom Meta Title
What is the extrafield's alias?

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

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

  • massimiliano
  • massimiliano's Avatar Topic Author
  • Offline
  • New Member
More
7 years 2 months ago #163937 by massimiliano
Replied by massimiliano on topic Items Custom Meta Title
Hi,
the extrafiled alias is this:
Alias: Metatitle

Could you please explain me exactly the code i have to copy, where and how?

I really would appreciate it!

Thank you very mutch for your patience

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #163969 by Krikor Boghossian
Replied by Krikor Boghossian on topic Items Custom Meta Title
The correct aliases for the code to work should be:
title_tag
meta_description

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