- Posts: 5
COMMUNITY FORUM
Separating H1 from <Title>
- Guy
- Topic Author
- Offline
- New Member
Less
More
6 years 3 weeks ago #170007
by Guy
Separating H1 from <Title> was created by Guy
Hi all,
At the moment, inside an item view - page title goes into <title> and also to Heading1 (AKA H1). That means, that they always identical and this is what I would like to change. I would like to determine what each would be in every item page.
What I managed to do:
Disable H1 in the Category > Item view settings
Added Manually in the editor <h1> tags.
So what's wrong? Under category view, I have now: the Item title and right after, the manual H1 I added, as part of the intro text. It looks bad (both to end-user and to search-engines)
Any help here would be appreciated.
Reference link
Thanks!
At the moment, inside an item view - page title goes into <title> and also to Heading1 (AKA H1). That means, that they always identical and this is what I would like to change. I would like to determine what each would be in every item page.
What I managed to do:
Disable H1 in the Category > Item view settings
Added Manually in the editor <h1> tags.
So what's wrong? Under category view, I have now: the Item title and right after, the manual H1 I added, as part of the intro text. It looks bad (both to end-user and to search-engines)
Any help here would be appreciated.
Reference link
Thanks!
Please Log in or Create an account to join the conversation.
- Guy
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
6 years 3 weeks ago #170018
by Guy
Replied by Guy on topic Separating H1 from <Title>
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
6 years 3 weeks ago #170024
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Separating H1 from <Title>
If you want to use a custom <title>, there's a better and more elegant way to do this (although your request is rare the least).
Simple create a new extra field of type "text" that you will call "Page Title". Assign it to an existing or new extra fields group. Then make sure this group is assigned to your K2 categories (you can use a single K2 category as "category template" as well so you don't re-do the settings for each category again and again - see the "inherit" option inside the category form).
Then follow this guide getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates to create your own set of K2 template overrides inside your Joomla template, so you can modify the output.
The point is this:
- Grab the value of the "Page Title" extra field directly: $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value (do this at the top of the item.php file)
- Reset the document title (right after "defined('_JEXEC') or die;") with:
Done.
Simple create a new extra field of type "text" that you will call "Page Title". Assign it to an existing or new extra fields group. Then make sure this group is assigned to your K2 categories (you can use a single K2 category as "category template" as well so you don't re-do the settings for each category again and again - see the "inherit" option inside the category form).
Then follow this guide getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates to create your own set of K2 template overrides inside your Joomla template, so you can modify the output.
The point is this:
- Grab the value of the "Page Title" extra field directly: $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value (do this at the top of the item.php file)
- Reset the document title (right after "defined('_JEXEC') or die;") with:
$pagetitle = $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value; // Replace EXTRAFIELD_ALIAS_HERE with probably "pagetitle"
$document = JFactory::getDocument();
$document->setTitle($pagetitle);
Done.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
6 years 3 weeks ago #170025
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Separating H1 from <Title>
FYI, customizations like this will come in the form of a new commercial offering for K2, pretty soon :)
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Guy
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
6 years 3 weeks ago #170036
by Guy
Replied by Guy on topic Separating H1 from <Title>
Hey Fotis,
First, thanks for the quick reply!
Second, I would like to see that you understood me correctly.
The normal "Title" of any K2 Item should go to <title>My Page Title</title> - as it was always...
The H1 - I would like to set it in the separate field and not through the content-editor.
Would this solution will answer this?
Thanks again,
First, thanks for the quick reply!
Second, I would like to see that you understood me correctly.
The normal "Title" of any K2 Item should go to <title>My Page Title</title> - as it was always...
The H1 - I would like to set it in the separate field and not through the content-editor.
Would this solution will answer this?
Thanks again,
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
6 years 3 weeks ago #170045
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Separating H1 from <Title>
Even simpler. Follow the process then to create a "Custom Title" extra field and replace:
With:(assuming you used "customtitle" as alias for that extra field)
Do the same in "category_item.php".
I urge to reconsider though this change as it requires lots of overrides in many more places as well (e.g. modules). Not to mention search results will not be very accurate if you use totally different custom titles from the actual given title in the K2 item form.
<?php echo $this->item->title; ?>
With:
<?php echo $this->item->extraFields->customtitle->value; ?>
Do the same in "category_item.php".
I urge to reconsider though this change as it requires lots of overrides in many more places as well (e.g. modules). Not to mention search results will not be very accurate if you use totally different custom titles from the actual given title in the K2 item form.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.