- Posts: 1
- Thank you received: 0
Custom Metadata
12 years 6 months ago #147426
by funkyasa
Custom Metadata was created by funkyasa
Hi there, i'm wondering what file that i have to edit to change the meta desc and meta keyword on a product page.
The meta desc and keywords on product page normally will use the product's metadata.
But if the product's metada empty, it will use the site's default meta keyword and description, am i right?
I wanted to change it's behaviour, so if the metadata of the product is empty, it will use my custom words instead of using site's default metadata.
If it's empty, i want to make something like: Get this $productname now for only $price ! Or find other similar product in $category.
I tried to check and change in view.html.php but i don't know which line to edit (or wrong file to edit?).
Please help me to locate which file to edit and what line / part of the file. Thanks a lot for the nice components that support J3!
The meta desc and keywords on product page normally will use the product's metadata.
But if the product's metada empty, it will use the site's default meta keyword and description, am i right?
I wanted to change it's behaviour, so if the metadata of the product is empty, it will use my custom words instead of using site's default metadata.
If it's empty, i want to make something like: Get this $productname now for only $price ! Or find other similar product in $category.
I tried to check and change in view.html.php but i don't know which line to edit (or wrong file to edit?).
Please help me to locate which file to edit and what line / part of the file. Thanks a lot for the nice components that support J3!
Please Log in or Create an account to join the conversation.
12 years 6 months ago #147436
by nicolas
Replied by nicolas on topic Custom Metadata
Hi,
It's indeed the components/com_hikashop/views/product/view.html.php file that you need to edit. It's those lines:
It's indeed the components/com_hikashop/views/product/view.html.php file that you need to edit. It's those lines:
Code:
$doc = JFactory::getDocument();
$product_name = $this->element->product_name;
$product_page_title = $this->element->product_page_title;
$product_description = $element->product_meta_description;
$product_keywords = $element->product_keywords;
if(!empty($this->element->main)){
$product_name = $this->element->main->product_name;
if(!empty($this->element->main->product_page_title)){
$product_page_title = $this->element->main->product_page_title;
}
if(!empty($this->element->main->product_meta_description)){
$product_description = $this->element->main->product_meta_description;
}
if(!empty($this->element->main->product_keywords)){
$product_keywords = $this->element->main->product_keywords;
}
}
if(!empty($product_keywords)){
$doc->setMetadata('keywords', $product_keywords);
}
if(!empty($product_description)){
$doc->setMetadata('description', $product_description);
}
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 23
- Thank you received: 0
10 years 1 month ago - 10 years 1 month ago #248285
by aran.gibbs
Replied by aran.gibbs on topic Custom Metadata
Hi Nicolas,
Is this tweak still valid? I'd like to be able to auto create Metadescription with Product Name, Brand, Category & Price if it's left blank?
To test I have set lines 1327-1329 to this:
But it still just seems to set the meta to the text from the product description.
Aran
(2.6.3 Business)
Is this tweak still valid? I'd like to be able to auto create Metadescription with Product Name, Brand, Category & Price if it's left blank?
To test I have set lines 1327-1329 to this:
Code:
if(!empty($product_description)){
$doc->setMetadata('description', $productname only $price);
}
But it still just seems to set the meta to the text from the product description.
Aran
(2.6.3 Business)
Last edit: 10 years 1 month ago by aran.gibbs.
Please Log in or Create an account to join the conversation.
10 years 1 month ago #248287
by nicolas
Replied by nicolas on topic Custom Metadata
Hi,
Sure, you need to add to the end of that code something like that:
Sure, you need to add to the end of that code something like that:
Code:
else{
$doc->setMetadata('description', 'My custom meta description');
}
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 23
- Thank you received: 0
10 years 1 month ago - 10 years 1 month ago #248333
by aran.gibbs
Replied by aran.gibbs on topic Custom Metadata
Hi,
Thanks for coming back to me. I've added that code but still no joy. I've attached a copy of the file.
Are you sure its not pulling it from somewhere else too? I'm editing the file stored in /components/com_hikashop/views/product and even if I delete that file completely it still just put the text from the product description into the meta data.
Aran
Thanks for coming back to me. I've added that code but still no joy. I've attached a copy of the file.
Are you sure its not pulling it from somewhere else too? I'm editing the file stored in /components/com_hikashop/views/product and even if I delete that file completely it still just put the text from the product description into the meta data.
Aran
Last edit: 10 years 1 month ago by Jerome.
Please Log in or Create an account to join the conversation.
10 years 1 month ago #248338
by nicolas
Replied by nicolas on topic Custom Metadata
Hi,
You're not editing the correct file. That's the view.feed.php but you need to edit the view.html.php file.
You're not editing the correct file. That's the view.feed.php but you need to edit the view.html.php file.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 23
- Thank you received: 0
10 years 1 month ago - 10 years 1 month ago #248387
by aran.gibbs
Replied by aran.gibbs on topic Custom Metadata
HI,
I am editing the view.html.php file. Must have attached the wrong one.
I am editing the view.html.php file. Must have attached the wrong one.
Last edit: 10 years 1 month ago by Jerome.
Please Log in or Create an account to join the conversation.
10 years 1 month ago #248390
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Replied by Jerome on topic Custom Metadata
Hi,
The code
is unfortunately incorrect, it is not a valid PHP code so I think it generates you fatal errors.
So I recommend you to use some like :
If you want to generate a string with variables, you need to "concat" them.
Such kind of modification requires some PHP/Development skills and if you want to add a price in the meta description, it will require a more complexe modification.
Regards,
The code
Code:
if(!empty($product_description)){
$doc->setMetadata('description', $productname only $price);
}
So I recommend you to use some like :
Code:
$doc->setMetadata('description', $product_name . ' - ');
Such kind of modification requires some PHP/Development skills and if you want to add a price in the meta description, it will require a more complexe modification.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
Time to create page: 0.246 seconds