Keyword

[SOLVED] Change Generic page title

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago - 9 years 3 months ago #144759 by jozsefke
[SOLVED] Change Generic page title was created by jozsefke
I have three K2 menu items on my site, all pointing to one or more K2 categories. The home page is also a K2 menu item. My problem is that the Generic page titles are behaving strangely. The search page title only displays correctly when the search is not initiated from the home page. When the search is done on the homepage, it only displays the site title with the home page title.

Unfortunately, it is the same with the date listings. Is there a way to make it display correctly in both cases? Also, is it possible to remove the site title, so it would only display "Search results for:"? I need to have the site title displayed in the browser though, so I wouldn't like to turn it off completely.
Last edit: 9 years 3 months ago by jozsefke.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #144775 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change Generic page title
You can create a new empty K3 categories menu item.
Leave the category selection empty and this way all orphan tags, search and date listings will be rendered from that menu item.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago #144793 by jozsefke
Replied by jozsefke on topic Change Generic page title
Thank you for your answer, Krikor. It displays the title correctly that way, however the links this way become mydomain/newmenualias/search?searchword=... instead of just mydomain/search?searchword=... which is much simpler and more elegant. Is it not possible to have the correct Generic page titles displayed when doing a search from the home page K2 categories menu item? Even if it takes modifying the core K2 files.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #144806 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change Generic page title
mydomain/search?searchword= means that the search/date results are being rendered through the home page. So you get back to initial issue.

However you can edit your template and hide all the module positions when the option is K2 ( JRequest::getCmd('option'); ) and the task is search ( JRequest::getCmd('task'); )

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago - 9 years 3 months ago #144807 by jozsefke
Replied by jozsefke on topic Change Generic page title
Wow, I didn't think it was that complicated. Now I understand why it is not possible to edit the title when the search is made from the home page. I don't understand though how hiding all the module positions would help. I know a few things about template overriding, but I am not deeply into that. Thank you.

Edit: I've got an idea, that I could create 2 'if' statements for the search and date listings inside the header part in generic.php and manually write out 'K2_SEARCH_RESULTS_FOR' and 'K2_ITEMS_FILTERED_BY_DATE'. Now I only need to know how could I write out the searched word and the selected date. Could you please tell me that?
Last edit: 9 years 3 months ago by jozsefke.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #144822 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change Generic page title
You can override the generic.php file, more info here - getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

Use the same method as described in my previous post but omit the option.

Eg: Use
if  ( JRequest::getCmd('task') == 'search')
or date and then print the language string you want to display.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago #144853 by jozsefke
Replied by jozsefke on topic Change Generic page title
Thank you for your help, I managed to implement it this way! I only have one more little problem with the date. I can display the date but the month is showed as a number and I don't know how to display it as text, so instead of '2015 6', I would have '2015 June'. I have tried it this way, but it still shows a number:
<?php echo JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JRequest::getInt('year').' '.JRequest::getInt('month', JText::_('F')); ?>

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

More
9 years 3 months ago #144877 by Lefteris
Replied by Lefteris on topic Change Generic page title
@jozsefke

You can try the following code:
<?php
$year =  JRequest::getInt('year');
$month = JRequest::getInt('month');
$month = str_pad($month, 2, "0", STR_PAD_LEFT);
$day = '01';
$date = $year.'-'.$month.'-'.$day;
echo date('Y F', strtotime($date));
?>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago #144900 by jozsefke
Replied by jozsefke on topic Change Generic page title
Thank you very much, it is working now!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #144904 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change Generic page title
We 're glad you sorted it out :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum