- Posts: 66
COMMUNITY FORUM
k2 page titles configure
- burnyourears
-
- Offline
- Senior Member
<?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 ...
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
$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);
Please Log in or Create an account to join the conversation.
- burnyourears
-
- Offline
- Senior Member
- Posts: 66
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? :/
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
<?php
$safe = array("", "", "", "");
$nonsafe = array("'", "\"", "", "#039;", "&");
$safemeta = str_replace( $nonsafe, $safe, $this->item->title);
echo $safemeta;
?>
Please Log in or Create an account to join the conversation.
- burnyourears
-
- Offline
- Senior Member
- Posts: 66
One last idea?
That's the code right now:
<?php
$safe = array("", "", "", "");
$nonsafe = array("'", "\"", "", "#039;", "&");
$safemeta = str_replace( $nonsafe, $safe, $this->item->title);
$newtitle = ($safemeta . ' | Review - XXX');
$document = JFactory::getDocument();
$document->setTitle($newtitle);
?>
Please Log in or Create an account to join the conversation.
- burnyourears
-
- Offline
- Senior Member
- Posts: 66
<?php
$safe = array("'");
$nonsafe = array("'");
$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
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Wilfried
-
- Offline
- Junior Member
- Posts: 22
<?php
$newtitle= $this->item->extraFields->EXTRAFIELDALIASHERE->value;
$document = JFactory::getDocument();
$document->setTitle($newtitle);
?>
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.
Please Log in or Create an account to join the conversation.
- Wilfried
-
- Offline
- Junior Member
- Posts: 22
Thanks
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Please Log in or Create an account to join the conversation.
- Wilfried
-
- Offline
- Junior Member
- Posts: 22
I have already an override. I am not an expert in programming. Which loop are you talking about?
In the editing options of the extrafield, I have to choose "text" if I want to add content. And the "text" category don't allow me to hide the tag in the frontend. Visitors will see the content of the tag and I only want this tag for changing the tag title.
I hope that you can understand my message.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Please Log in or Create an account to join the conversation.
- Wilfried
-
- Offline
- Junior Member
- Posts: 22
I'm gonna search again and maybe I will find a solution.
Thak you for your help.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Please Log in or Create an account to join the conversation.
- Dejan Bojovic
-
- Offline
- New Member
- Posts: 17
<?php
$newtitle= $this->item->extraFields->Naslov->value;
$document = JFactory::getDocument();
$document->setTitle($newtitle);
?>
but if the extra field is empty, the page link is displayed.
Is it possible to display the default page title if the extra field is empty?
sorry find solution:
<?php
$doc = JFactory::getDocument();
if ( isset( $this->item->extraFields->Naslov->value ) && ($this->item->extraFields->Naslov->value !=='') ) {
$doc->setTitle('<title>'.$this->item->extraFields->Naslov->value.'</title>');
}
?>
Please Log in or Create an account to join the conversation.