I'm not looking to add anything in the <head> portion...but just in the main body of the product.tpl file located at catalog/view/theme/default/template/product/product.tpl
I've tried all sorts of different things and I still can't figure this one out. I'm trying to display the contents of the meta_description field somewhere on the page and not just in the <head> -- how can I do this?
Thanks!
I've tried all sorts of different things and I still can't figure this one out. I'm trying to display the contents of the meta_description field somewhere on the page and not just in the <head> -- how can I do this?
Thanks!
1. EDIT: catalog/controller/product/product.php
2. FIND:
3. AFTER, ADD:
4. EDIT: catalog/view/theme/YOURTHEME/template/product/product.tpl
5. PASTE THIS WHERE YOU WANT IT:
2. FIND:
Code: Select all
$this->document->description = $product_info['meta_description'];
Code: Select all
$this->data['meta_description'] = $product_info['meta_description'];
5. PASTE THIS WHERE YOU WANT IT:
Code: Select all
<?php echo $meta_description; ?>
What will this do excactly?
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
Q, what if I want to do the same thing on the category.tpl page?
What exactly do i need to insert into the category controller?
I tried finding this:
And adding this AFTER:
And tried calling it with <?php echo $meta_description; ?> in the category.tpl template....but no luck.
Any ideas?
What exactly do i need to insert into the category controller?
I tried finding this:
Code: Select all
$this->document->description = $category_info['meta_description'];
Code: Select all
$this->data['meta_description'] = $category_info['meta_description'];
Any ideas?
Oops, i just realized i wrote $category_info up there....what I meant to say is that i want that same product meta_description that Q helped me display to show up next to each product in the category view...and NOT the category's meta description.
Hope that makes sense.
Hope that makes sense.
1. EDIT: catalog/controller/product/category.php
2. FIND:
3. AFTER, ADD:
4. EDIT: catalog/view/....../product/category.tpl
5. FIND:
6. AFTER, ADD:
2. FIND:
Code: Select all
'model' => $result['model'],
Code: Select all
'meta_description' => $result['meta_description'],
5. FIND:
Code: Select all
<?php if ($products[$j]['rating']) { ?>
<img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
<?php } ?>
Code: Select all
<?php if ($products[$j]['meta_description']) { ?>
<?php echo $products[$j]['meta_description']; ?>"
<?php } ?>
Any idea how I can do the same for the meta keyword field?
I tried doing it with the exact directions above but it appears that this field might behave a bit differently and it doesn't show up on either the product or category pages.
Thanks!
I tried doing it with the exact directions above but it appears that this field might behave a bit differently and it doesn't show up on either the product or category pages.
Thanks!
I understand but I'm just trying to re-use this field for another purpose like I did with the meta description product field.Qphoria wrote:There is no meta keyword field. The keyword is for SEO urls. Meta keywords have been deemed useless for the past 2 years (google some info about it).
Try this in the product.tpl:
Code: Select all
<?php
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query = 'product_id=" . (int)$product_id . "'");
echo $query->row['keyword'];
?>
Yes.dashik wrote:Anyone know how i can call the product_id of each listing in the category.tpl template file?
/catalog/controller/product/product.php
About line 143, you'll see something like this:
Code: Select all
$this->data['products'][] = array(
'name' => $result['name'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'thumb' => image_resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
'price' => $price,
'special' => $special,
'page_url' => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id'])),
'href' => $this->model_tool_seo_url->rewrite($this->url->http('product/product&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']))
);
Code: Select all
$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
'sku' => $result['sku'],
'id' => $result['product_id'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'thumb' => image_resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
'price' => $price,
'special' => $special,
'page_url' => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id'])),
'href' => $this->model_tool_seo_url->rewrite($this->url->http('product/product&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']))
);
Code: Select all
<?php echo $products[$j]['sku']; ?>
<?php echo $products[$j]['model']; ?>
<?php echo $products[$j]['id']; ?>
catalog/view/theme/default/template/product/category.tpl
In the section that starts off like:
Code: Select all
<?php for ($i = 0; $i < sizeof($products); $i = $i + 2) { ?>
<tr>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<td width="25%"><?php if (isset($products[$j])) { ?>
Matt
Code: Select all
It was like that when I found it, honest!
moggiex -- for some reason, that's not working for me.
this is what my product array looked like before:
And after:
But category.tpl still won't call the product_id using
Keep in mind I am running 1.3.0 -- is there anything else I need to be doing?
Thanks!
this is what my product array looked like before:
Code: Select all
$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'thumb' => HelperImage::resize($image, $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')),
'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
'special' => $special,
'href' => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
);
Code: Select all
$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
'id' => $result['product_id'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'thumb' => HelperImage::resize($image, $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')),
'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
'special' => $special,
'href' => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
);
Code: Select all
<?php echo $products[$j]['id']; ?>
Thanks!
Who is online
Users browsing this forum: Semrush [Bot] and 215 guests