Post by jonnylaris » Mon Jun 03, 2013 6:48 pm

Really simple question, how do I display the meta description for the products on the category page?

I tried putting this in category.tpl:

Code: Select all

<?php echo $product_info['meta_description']; ?>
..but I get an error "Undefined variable: product_info..."

Newbie

Posts

Joined
Tue Sep 18, 2012 9:49 pm

Post by jonnylaris » Mon Jun 03, 2013 8:48 pm

Anyone?

£5 to anyone who can sort this out for me :)

Newbie

Posts

Joined
Tue Sep 18, 2012 9:49 pm

Post by labeshops » Mon Jun 03, 2013 10:05 pm

You need to add the variable to the catalog/controller/product/category.php

It looks like it already calls the model file, so you should just have to add a definition for the description. Haven't tested it, but try adding

Code: Select all

$this->document->setDescription($product_info['meta_description']);
probably after

Code: Select all

$results = $this->model_catalog_product->getProducts($data);
would work.

Running Opencart v3.0.3.2 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by jonnylaris » Mon Jun 03, 2013 11:20 pm

Thanks for the reply.

After entering your code I am unfortunately still getting the error:

With <?php echo $meta_description; ?> the error reads "Notice: Undefined variable: meta_description"...

With <?php echo $product_info['meta_description']; ?> the error reads "Notice: Undefined variable: product_info"...

Newbie

Posts

Joined
Tue Sep 18, 2012 9:49 pm

Post by jonnylaris » Mon Jun 03, 2013 11:44 pm

Nevermind I figured it out myself :)

Code: Select all

<?php echo $product['meta_description']; ?>
"product_info" should just be "product".

And I added this to category.tpl:

Code: Select all

'meta_description' => html_entity_decode($result['meta_description'], ENT_QUOTES, 'UTF-8'),
Just after:

Code: Select all

'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),

Newbie

Posts

Joined
Tue Sep 18, 2012 9:49 pm

Post by sinners » Tue Apr 13, 2021 7:51 pm

Hi, did you do this so all titles would go in meta desc?? if so how did you do it. i can not work it out from what was posted.
so all you did was just put in the category.tpl

<?php echo $product['meta_description']; ?>'meta_description' => html_entity_decode($result['meta_description'], ENT_QUOTES, 'UTF-8'),'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'),

in the category.tpl you are using was it catalog/view/theme/mytemplate/template/product/category.tpl, or does it have to go in default.

Head in battered, tried so many different ways.

Thanks

Newbie

Posts

Joined
Thu Jul 05, 2018 4:59 am

Post by by mona » Wed Apr 14, 2021 8:08 pm

No idea what OC version which is highlighted as to why they ‘figured it out’ ..
but since this is posted in OC1.5+ one has to assume.
and you are using a theme presumably.

Code: Select all

$this->document->setDescription($product_info['meta_description']);
is category.php

Code: Select all

<?php echo $product['meta_description']; ?>
is category.tpl

catalog/view/theme/mytemplate/template/product/category.tpl, or does it have to go in default
If you are using a template.
default is you are using default
both if you switch

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by jansey » Sun Jun 06, 2021 6:08 pm

I have that same problem. I'm looking for support from knowledgeable people. Otherwise I will have to restore the site. I am in a really frustrating situation. I want to do this myself without paying someone. I hope someone will come out to help me.
Last edited by jansey on Mon Jun 07, 2021 4:33 pm, edited 1 time in total.

Newbie

Posts

Joined
Fri Jun 04, 2021 9:27 pm

Post by straightlight » Sun Jun 06, 2021 6:50 pm

jansey wrote:
Sun Jun 06, 2021 6:08 pm
I have that same problem. I'm looking for support from knowledgeable people. Otherwise I will have to restore the site. I am in a really frustrating situation. I want to do this myself without paying someone. I hope someone will come out to help me.
Then, using Google would be your best bet.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 34 guests