Keyword

Separating H1 from <Title>

More
2 weeks 2 days ago #170007 by Guy
Guy created the topic: Separating H1 from <Title>
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!

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

More
2 weeks 2 days ago #170018 by Guy
Guy replied the topic: Separating H1 from <Title>
Adding an image for better understanding:

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
2 weeks 2 days ago #170024 by Fotis
Fotis replied the 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:
$pagetitle = $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value; // Replace EXTRAFIELD_ALIAS_HERE with probably "pagetitle"
$document = JFactory::getDocument();
$document->setTitle($pagetitle);

Done.


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
2 weeks 2 days ago #170025 by Fotis
Fotis replied the topic: Separating H1 from <Title>
FYI, customizations like this will come in the form of a new commercial offering for K2, pretty soon :)


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

More
2 weeks 1 day ago #170036 by Guy
Guy replied the 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,

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
2 weeks 1 day ago #170045 by Fotis
Fotis replied the topic: Separating H1 from <Title>
Even simpler. Follow the process then to create a "Custom Title" extra field and replace:
<?php echo $this->item->title; ?>

With:
<?php echo $this->item->extraFields->customtitle->value; ?>
(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.


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

Moderators: william white