Keyword

k2 page titles configure

  • Roman Lipatov
  • Roman  Lipatov's Avatar Topic Author
  • Offline
  • New Member
More
9 years 6 months ago - 9 years 6 months ago #145737 by Roman Lipatov
k2 page titles configure was created by Roman Lipatov
Hi!
I need to create page title tags not same as item title.
So, if item title = item title, I need page title tag = my specific page title.
I think, I can do it using k2 extra fields.
But I can't find which file to edit — to set my page title tag = extra field with ID 1 (example).
Can you point me in right direction?
Thanks!
Last edit: 9 years 6 months ago by Roman Lipatov.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 6 months ago #145756 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
Hello,
You need to override the item.php file.
This post will help you locate it: 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.

  • Roman Lipatov
  • Roman  Lipatov's Avatar Topic Author
  • Offline
  • New Member
More
9 years 6 months ago #145769 by Roman Lipatov
Replied by Roman Lipatov on topic k2 page titles configure
Ok, thanks.
But where in this file page title tag variable?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 6 months ago #145780 by Krikor Boghossian
Replied by Krikor Boghossian on topic k2 page titles configure
You can paste it in the itemHeader div, directly under the item's title.

Extrafields can be directly rendered in your template so you do not have to move the entire extrafields block.

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

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

  • Roman Lipatov
  • Roman  Lipatov's Avatar Topic Author
  • Offline
  • New Member
More
9 years 6 months ago - 9 years 6 months ago #145790 by Roman Lipatov
Replied by Roman Lipatov on topic k2 page titles configure
You probably didn't understand me...
I'm talking about meta tag Page title




I need to replace default meta tag <title> which is equal of k2 item title, on my own (for example k2 extra field)
Last edit: 9 years 6 months ago by Roman Lipatov.

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

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
9 years 6 months ago #145796 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic k2 page titles configure
Like what Krikor said, you just have to override item.php

To add custom page title based on your extra field value, try this
<?php
$newtitle= $this->item->extraFields->EXTRAFIELDALIASHERE->value;
$document = JFactory::getDocument();
$document->setTitle($newtitle);
?>

Simply replace EXTRAFIELDALIASHERE with the actual alias of the extra field you wish to output.

K2 Rocks \m/

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

  • Roman Lipatov
  • Roman  Lipatov's Avatar Topic Author
  • Offline
  • New Member
More
9 years 6 months ago #145797 by Roman Lipatov
Replied by Roman Lipatov on topic k2 page titles configure
Awesome!
Thanks!
It's works perfect :)

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

More
8 years 4 months ago #158075 by Giorgio Basile
Replied by Giorgio Basile on topic k2 page titles configure
Hi,

I would like to do the same but is not working for me.
I did override and pasted the code Kannan published with the correct Extra Fields alias in the item.php but now I have as Browser Page Title the page url and in the page code the meta name title has always the K2 article title.
Check this page : new.verticalife.it/index.php/it/viaggi-trekking-in-nepal/templi-e-vette-dell-himalaya

I've pasted it here :
<div class="itemHeader">
	
     <?php
		$newtitle= $this->item->extraFields->PageTitle->value;
		$document = JFactory::getDocument();
		$document->setTitle($newtitle);
		?>

	<?php if($this->item->params->get('itemDateCreated')): ?>
	<!-- Date created -->

"PageTitle" is my Extra Fileds alias.

Can you please help me?

Many thanks!

Giorgio

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

  • Kannan Naidu Venugopal
  • Kannan Naidu Venugopal's Avatar
  • Offline
  • Platinum Member
  • Aham Brahmasmi
More
8 years 4 months ago #158078 by Kannan Naidu Venugopal
Replied by Kannan Naidu Venugopal on topic k2 page titles configure
Hi,

Can you check if the extrafields is set to show in the configuration parameters?

K2 Rocks \m/

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

More
7 years 10 months ago #161297 by Martin Richta
Replied by Martin Richta on topic k2 page titles configure
Hi. I have problem with title tag too. K2 adding to title my website name. I cant use it. i need only title (page name) without any items. And my sh404sef add behind itle my custom text.

any idea how i can set up it?

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

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

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 2 months ago - 7 years 2 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 2 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 2 months ago - 7 years 2 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 2 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 2 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 2 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 2 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 2 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 2 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 2 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 2 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.


Powered by Kunena Forum