Change Page Title when filter used.

  • Posts: 177
  • Thank you received: 5
11 years 7 months ago #105394

How can I add to page title, what I selected in filter?

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

  • Posts: 13201
  • Thank you received: 2322
11 years 7 months ago #105404

Hi,

You will probably have to edit the file "components/com_hikashop/views/product/view.html.php" and in the function "listing()" get the value of the filter, then you will find the code "$document->setTitle(strip_tags($page_title));" which is displaying the page title, you have to change the value of the var $page_title by the title with the filter value.

It require PHP knowledge.

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

  • Posts: 177
  • Thank you received: 5
11 years 7 months ago #105444

Xavier wrote: Hi,

You will probably have to edit the file "components/com_hikashop/views/product/view.html.php" and in the function "listing()" get the value of the filter, then you will find the code "$document->setTitle(strip_tags($page_title));" which is displaying the page title, you have to change the value of the var $page_title by the title with the filter value.

It require PHP knowledge.

Can you explain more detailed please? Different page titles important for googlebot.

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

  • Posts: 177
  • Thank you received: 5
11 years 7 months ago #105448

When I change $document->setTitle(strip_tags('tttteeest'.$page_title)); in "components/com_hikashop/views/product/view.html.php" - nothing change.

When change $document->setTitle( strip_tags('teeeest'.$product_name) ); in this file - changed Page Title for detailed product description. But I need Page Title in listing category products.

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

  • Posts: 177
  • Thank you received: 5
11 years 7 months ago #105449

In "/administrator/components/com_hikashop/classes/filter.php" add:

session_start();
$_SESSION['current_filter_my']=$val[1];

And in "components/com_hikashop/views/category/view.html.php" add:
session_start();
$document->setTitle(strip_tags($_SESSION['current_filter_my']." ".$page_title));

Now in Page Title i see previous selected option in filter, not current(

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

  • Posts: 13201
  • Thank you received: 2322
11 years 7 months ago #105483

You can edit the class Filter, in "administrator/components/com_hikashop/classes/field.php", in the function corresponding to the filter type, add the following code where you find selected="selected"

$doc = JFactory::getDocument(); $doc->setTitle($value);

For example if the filter is a single dropdow based on the price add the code in the "hikashopSingledropdownClass" class function "display()" int the //DISPLAY PRICES OR INFORMATION part.

Hope this will help you.

The following user(s) said Thank You: alikon1

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

  • Posts: 177
  • Thank you received: 5
11 years 7 months ago #105508

Xavier wrote: You can edit the class Filter, in "administrator/components/com_hikashop/classes/field.php", in the function corresponding to the filter type, add the following code where you find selected="selected"

$doc = JFactory::getDocument(); $doc->setTitle($value);

For example if the filter is a single dropdow based on the price add the code in the "hikashopSingledropdownClass" class function "display()" int the //DISPLAY PRICES OR INFORMATION part.

Hope this will help you.


Thank you. It works.
$doc = JFactory::getDocument();	$page_title = $doc->getTitle();	$doc->setTitle($val[1].' '.$page_title);
But could not understand why it duplicate $val[1]. In Page title I see it 2 times.

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

  • Posts: 177
  • Thank you received: 5
11 years 7 months ago #105511

Found about str_replace in PHP documentation.

$doc = JFactory::getDocument();
$page_title = str_replace($val[1],'-',$doc->getTitle());
$doc->setTitle($val[1].' '.$page_title);

Looks like it works now.

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

Time to create page: 0.078 seconds
Powered by Kunena Forum