- Posts: 6
COMMUNITY FORUM
Custom Page Title
- Ethan
- Topic Author
- Offline
- New Member
Less
More
14 years 6 months ago #81478
by Ethan
Custom Page Title was created by Ethan
Is it possible with K2 to add a custom page title for SEO purposes?
Please Log in or Create an account to join the conversation.
- Ethan
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
14 years 6 months ago #81479
by Ethan
Replied by Ethan on topic Custom Page Title
Anyone? In case I wasn't clear, what I want is the ability to name my articles/posts one thing, but create an alternate "page title" that is SEO friendly. I've done this in the past with plugins that work with the core joomla articles, but I haven't found anything for K2. Please let me know if this exists. Thanks.
Please Log in or Create an account to join the conversation.
- Björn Meyer
- Offline
- New Member
Less
More
- Posts: 9
14 years 6 months ago #81480
by Björn Meyer
Replied by Björn Meyer on topic Custom Page Title
How can i add the name of the category to the page title ?
Please Log in or Create an account to join the conversation.
- Andrew Holden
- Offline
- New Member
Less
More
- Posts: 15
14 years 3 months ago #81481
by Andrew Holden
Replied by Andrew Holden on topic Custom Page Title
There is a small solution possible. Try the 'Website Name' or another 'append-a-site-title' extension, so that you can append the title of your site to the existing page title.
It works with K2, too:
extensions.joomla.org/extensions/site-management/seo-a-metadata/3352
While this doesn't let you specify page titles per se, if your page titles and articles titles are so different that you need to specify, you probably aren't writing very good article titles anyway. (in most cases)
It works with K2, too:
extensions.joomla.org/extensions/site-management/seo-a-metadata/3352
While this doesn't let you specify page titles per se, if your page titles and articles titles are so different that you need to specify, you probably aren't writing very good article titles anyway. (in most cases)
Please Log in or Create an account to join the conversation.
- Davina
- Offline
- New Member
Less
More
- Posts: 7
14 years 2 months ago #81482
by Davina
Replied by Davina on topic Custom Page Title
I've done so using the Custom Page Title plugin.
The plugin calls on the Key Reference field, which K2 doesn't include in the metadata options for its content items, but it's possible to add this by adding the following line of code to administrator/components/com_k2/models/item.xml:
<param name="keyref" type="text" size="25" default="" label="Key Reference" description="PARAMKEYREF" />
Since the K2 display doesn't call on all the same functions as displaying a Joomla article, I then copied the following code from components/com_content/views/article/view.html.php to components/com_k2/views/item/view.html.php:
* Handle display events
*/
$article->event = new stdClass();
$results = $dispatcher->trigger('onAfterDisplayTitle', array (&$article, &$params, $limitstart));
$article->event->afterDisplayTitle = trim(implode("\n", $results));
Hope this helps. Seems to be working for me anyway :)
The plugin calls on the Key Reference field, which K2 doesn't include in the metadata options for its content items, but it's possible to add this by adding the following line of code to administrator/components/com_k2/models/item.xml:
<param name="keyref" type="text" size="25" default="" label="Key Reference" description="PARAMKEYREF" />
Since the K2 display doesn't call on all the same functions as displaying a Joomla article, I then copied the following code from components/com_content/views/article/view.html.php to components/com_k2/views/item/view.html.php:
* Handle display events
*/
$article->event = new stdClass();
$results = $dispatcher->trigger('onAfterDisplayTitle', array (&$article, &$params, $limitstart));
$article->event->afterDisplayTitle = trim(implode("\n", $results));
Hope this helps. Seems to be working for me anyway :)
Please Log in or Create an account to join the conversation.
- John mcelborough
- Offline
- New Member
Less
More
- Posts: 10
14 years 1 month ago #81483
by John mcelborough
Replied by John mcelborough on topic Custom Page Title
Björn said:How can i add the name of the category to the page title ?
Hi, know this is old but in case anyone else is still looking to do this...
In components/ com_k2/views/item open item.html.php
Around line 236 replace...
//$params->set('page_title', $item->cleanTitle);
with
$params->set('page_title', $item->cleanTitle . ' - ' . $item->category->name);
Hope this helps
Hi, know this is old but in case anyone else is still looking to do this...
In components/ com_k2/views/item open item.html.php
Around line 236 replace...
//$params->set('page_title', $item->cleanTitle);
with
$params->set('page_title', $item->cleanTitle . ' - ' . $item->category->name);
Hope this helps
Please Log in or Create an account to join the conversation.
- ak2user
- Offline
- New Member
Less
More
- Posts: 19
14 years 4 weeks ago #81484
by ak2user
Replied by ak2user on topic Custom Page Title
To John mcelborough:
I’m still tackling this issue, so thanks for the tip.
I need the title to be formatted as follows:
Parent category | Child category | Item
Perhaps you can help with that. With your previous suggestion I get:
Item - Child category
I’m still tackling this issue, so thanks for the tip.
I need the title to be formatted as follows:
Parent category | Child category | Item
Perhaps you can help with that. With your previous suggestion I get:
Item - Child category
Please Log in or Create an account to join the conversation.
- John mcelborough
- Offline
- New Member
Less
More
- Posts: 10
14 years 4 weeks ago #81485
by John mcelborough
Replied by John mcelborough on topic Custom Page Title
Hi
$params->set('page_title', $item->category->name . ' | ' . $item->cleanTitle);
Should give you:
Child category | Item
Sorry I'm not sure how to access the parent category but sure there is a way.
John
ak2user said:To John mcelborough:
I’m still tackling this issue, so thanks for the tip.
I need the title to be formatted as follows:
Parent category | Child category | Item
Perhaps you can help with that. With your previous suggestion I get:
Item - Child category
$params->set('page_title', $item->category->name . ' | ' . $item->cleanTitle);
Should give you:
Child category | Item
Sorry I'm not sure how to access the parent category but sure there is a way.
John
ak2user said:To John mcelborough:
I’m still tackling this issue, so thanks for the tip.
I need the title to be formatted as follows:
Parent category | Child category | Item
Perhaps you can help with that. With your previous suggestion I get:
Item - Child category
Please Log in or Create an account to join the conversation.
- ak2user
- Offline
- New Member
Less
More
- Posts: 19
14 years 4 weeks ago #81486
by ak2user
Replied by ak2user on topic Custom Page Title
Thanks for your assistance. Now I need somehow to find out how to add the missing piece.
Please Log in or Create an account to join the conversation.
- Paul
- Offline
- Senior Member
Less
More
- Posts: 58
13 years 11 months ago #81487
by Paul
Replied by Paul on topic Custom Page Title
Cant seem to find this file in the link - com_k2/views/item open item.html.php
Can you confirm?
Cheers Pd
John mcelborough said:Björn said:How can i add the name of the category to the page title ?
Hi, know this is old but in case anyone else is still looking to do this...
In components/ com_k2/views/item open item.html.php
Around line 236 replace...
//$params->set('page_title', $item->cleanTitle);
with
$params->set('page_title', $item->cleanTitle . ' - ' . $item->category->name);
Hope this helps
Can you confirm?
Cheers Pd
John mcelborough said:Björn said:How can i add the name of the category to the page title ?
Hi, know this is old but in case anyone else is still looking to do this...
In components/ com_k2/views/item open item.html.php
Around line 236 replace...
//$params->set('page_title', $item->cleanTitle);
with
$params->set('page_title', $item->cleanTitle . ' - ' . $item->category->name);
Hope this helps
Please Log in or Create an account to join the conversation.