- Posts: 6
COMMUNITY FORUM
Custom Page Title
- Ethan
-
Topic Author
- Offline
- New Member
Please Log in or Create an account to join the conversation.
- Ethan
-
Topic Author
- Offline
- New Member
- Posts: 6
Please Log in or Create an account to join the conversation.
- Björn Meyer
-
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Andrew Holden
-
- Offline
- New Member
- Posts: 15
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
- Posts: 7
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
- Posts: 10
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
- Posts: 19
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
- Posts: 10
$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
- Posts: 19
Please Log in or Create an account to join the conversation.
- Paul
-
- Offline
- Senior Member
- Posts: 58
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.
- ak2user
-
- Offline
- New Member
- Posts: 19
Please Log in or Create an account to join the conversation.
- Daphne Christoforidou
-
- Offline
- New Member
- Posts: 14
$params->set('page_title', $item->cleanTitle);
appears on line 233 and 236. Is it ok if we replace it in both cases or do we just have to replace line 236 and not line 233? I'm pasting the whole if clause here for anyone interested (it's after I applied the fix and as you can see I have commented out both line 233 and 236 and replaced them) :
//Set page title $menus = &JSite::getMenu(); $menu = $menus->getActive(); if (is_object($menu) && isset($menu->query) && $menu->query == 'item' && isset($menu->query) && $menu->query == $item->id) { $menu_params = new JParameter($menu->params); if (!$menu_params->get('page_title')) { //$params->set('page_title', $item->cleanTitle); $params->set('page_title', $item->cleanTitle . ' | ' . $item->category->name); } } else { //$params->set('page_title', $item->cleanTitle); $params->set('page_title', $item->cleanTitle . ' | ' . $item->category->name); } $document->setTitle($params->get('page_title'));
Please Log in or Create an account to join the conversation.
- rexkramer
-
- Offline
- Senior Member
- Posts: 71
iJoomla SEO does support K2 and many other components.
Please Log in or Create an account to join the conversation.
- matt haeck
-
- Offline
- New Member
- Posts: 2
Please Log in or Create an account to join the conversation.
- rosy jenith
-
- Offline
- New Member
- Posts: 2
Please Log in or Create an account to join the conversation.
- Dave W
-
- Offline
- New Member
- Posts: 9
Comment out or remove Line 248.
Replace with: $params->set('page_title', $item->cleanTitle . ' - ' . $item->category->name);
Line 248: // $params->set('page_title', $item->cleanTitle);
$params->set('page_title', $item->cleanTitle . ' - ' . $item->category->name);
Please Log in or Create an account to join the conversation.