Page 1 of 1
Description meta tag not available on information pages
Posted: Mon Oct 18, 2010 5:10 pm
by vayu
Hi,
I was wondering if it is possible to have a description meta box on information pages?
I wonder why this is not available there?
Cordially
Vayu
Re: Description meta tag not available on information pages
Posted: Mon Oct 18, 2010 7:11 pm
by JAY6390
it wouldn't be that hard to add, you'd need to just add a field to the information_description table, add in the box, and update the column like the rest are. Have you searched the forums regarding this, I'm sure someone else will have wanted this before now, and there may already be exact instructions on how to add it
Re: Description meta tag not available on information pages
Posted: Mon Oct 18, 2010 8:55 pm
by vayu
Hi Jay,
thanks for helping out.
Yes, I have searched the forum for this topic and only found one other person who had posted the same question, but there was no answer.
http://forum.opencart.com/viewtopic.php ... ion#p90847. I do apologize if I have missed other posts about this.
Adding a field to the information_description table sounds like hacking core files, is that correct? I would rather not hack core files if I can avoid it. However, if this requires hacking core file, which files would it need to be modified? If not, then I don't know how to this via the admin.
Thanks
Vayu
Re: Description meta tag not available on information pages
Posted: Mon Oct 18, 2010 9:06 pm
by JAY6390
It will require a number of core edits, to information/information.[tpl/php] files in most folders
Re: Description meta tag not available on information pages
Posted: Mon Oct 18, 2010 9:10 pm
by vayu
thanks again, I will have a look at it.
Re: Description meta tag not available on information pages
Posted: Fri Oct 29, 2010 1:02 am
by onlinesunshine
Is anyone able to help here? It seems like it should be easy but I'm not a programmer
I've done the following:
- Admin/controller/catalog/information/information.php
added in
Code: Select all
$this->data['entry_meta_description'] = $this->language->get('entry_meta_description');
to line 273
- Admin/language/english/catalog/information.php
added in the line
Code: Select all
$_['entry_meta_description'] = 'Meta Tag Description:';
to line 17
- Admin/view/template/catalog/information_form.tpl
Added in
Code: Select all
<tr>
<td><?php echo $entry_meta_description; ?></td>
<td><textarea name="information_description[<?php echo $language['language_id']; ?>][meta_description]" cols="40" rows="5"><?php echo isset($information_description[$language['language_id']]) ? $information_description[$language['language_id']]['meta_description'] : ''; ?></textarea></td>
</tr>
to line 26
I've also added a field in the database under 'information_description' called 'meta_desciption'
I can now see a field for Meta Desciption in the Information page in the admin section, but it has
"<b>Notice</b>: Undefined index: meta_description in ****/admin/view/template/catalog/information_form.tpl</b> on line <b>38</b>"
within it. Would love some help here!!!
Re: Description meta tag not available on information pages
Posted: Fri Dec 31, 2010 3:39 am
by webdude
onlinesunshine- What you have done is correct but to make it work you need to add some more changes to the model file. Here are the steps I have done to add meta description and meta keywords to my information pages...
(I'm using the latest version of OpenCart V1.4.9.3)
1) Add the two fields needed to store the data for each information page.
Using PHPMyAdmin or similar, run the following SQL:
Code: Select all
ALTER TABLE `information_description` ADD `meta_description` VARCHAR( 255 ) NOT NULL, ADD `meta_keywords` VARCHAR( 255 ) NOT NULL
2) Add the extra text boxes to the admin page:
admin/view/template/catalog/information_form.tpl
Insert at line 36
Code: Select all
<tr>
<td><?php //echo $entry_meta_description; ?>Meta Description</td>
<td><textarea name="information_description[<?php echo $language['language_id']; ?>][meta_description]" cols="40" rows="5"><?php echo isset($information_description[$language['language_id']]) ? $information_description[$language['language_id']]['meta_description'] : ''; ?></textarea></td>
</tr>
<tr>
<td><?php //echo $entry_meta_keywords; ?>Meta Keywords</td>
<td><textarea name="information_description[<?php echo $language['language_id']; ?>][meta_keywords]" cols="40" rows="5"><?php echo isset($information_description[$language['language_id']]) ? $information_description[$language['language_id']]['meta_keywords'] : ''; ?></textarea></td>
</tr>
Note: I'm being lazy here and hard coding the descriptions into the template file. Really this text should be put in the language file and loaded in the controller file. Since OnlineSunshine has shown how to do this in her post I'll leave this out. Personally I'm happy that the admin will only ever be seen in English and that the less changes I have to make the better as installing the next version of OC usually means making these changes again!
3) Add the extra fields into the model file
admin/model/catalog/information.php
lines
9 and
31 are SQL statements that insert the data into the DB when you add or edit an information page.
Replace
BOTH these lines with this one which includes the extra fields on the end.
Code: Select all
$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET information_id = '" . (int)$information_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_description = '".$this->db->escape($value['meta_description'])."', meta_keywords = '".$this->db->escape($value['meta_keywords'])."'");
There is also a third change to make further down where the data is loaded from the DB
replace line 125 with...
Code: Select all
'description' => $result['description'],'meta_description' => $result['meta_description'],'meta_keywords' => $result['meta_keywords']
4) Make the data available when you view an information page
/catalog/controller/information/information.php
line 26 add the following...
Code: Select all
$this->document->description = $information_info['meta_description']; $this->document->keywords = $information_info['meta_keywords'];
There you have it! Lets vote to add this to the next release of OC

Re: Description meta tag not available on information pages
Posted: Fri Oct 07, 2011 7:23 am
by GFR_Web
Does anyone know if this is something which has been incorporated into recent OC releases?
Re: Description meta tag not available on information pages
Posted: Fri Nov 16, 2012 3:17 am
by Zohaib
One thing to correct here is:
In Step 4 by webdude:
Rather adding this:
Code: Select all
$this->document->description = $information_info['meta_description']; $this->document->keywords = $information_info['meta_keywords'];
Add this:
Code: Select all
$this->document->setDescription($information_info['meta_description']);
$this->document->setKeywords($information_info['meta_keywords']);
This will work 100% guranteed!!!
I really appreciate the contribution done by onlinesunshine & webdude.
Tested successfully on opencart ver. 1.5.1.1
Thank You!

Re: Description meta tag not available on information pages
Posted: Tue May 07, 2013 2:40 am
by Sanek
Does not work in version 1.5.5.1
Please help!
Re: Description meta tag not available on information pages
Posted: Tue May 07, 2013 4:08 pm
by Sanek
does not save fields in db (meta_description, meta_keywords)
follow this instructions
http://www.opencart.com/index.php?route ... on_id=4702
UPDATE:
for 1.5.5.1
working code:
http://www.expertwebadvisor.com/adding- ... -opencart/