I'm currently creating / integrating my own theme. I'm aware it's a big 'no-no' to edit the content in the 'catalog/view/theme/default' folder and so I've created my own theme folder and have set it in the Admin area as the theme which should be used for the store front – so far, so good!
Now, I'm having a little difficulty bringing some dynamic content into my new theme. The header is working well and pulling in the logo I uploaded to the database via the Admin area, but I'm receiving an error in the footer when trying to display the logo there too:
"Notice: Undefined variable: logo in /catalog/view/theme/myTheme/template/common/footer.tpl"
I'm guessing this is something to do with the Controller files not supplying the information to the footer.tpl file.
So, my question is: What files am I 'allowed' to update and which files am I not? I wouldn't want to update any Controller files (or anything else) for them to be overwritten with the next OpenCart update!
Many thanks!
Look in the catalog/controller/common/header.php and copy the code for $data['logo'] into the footer controller.
Better is to use OCMOD to apply your changes.
For the new upcoming OC it's below code but is similar(*) for older versions.
Code: Select all
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}
If you need an example for an OCMOD, let me know. It's really easy.
Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
Thank you for your reply!
I copied the below code from the header and pasted it into the footer controller, but I'm worried future updates would delete this?
Code: Select all
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}
Thank you!
It's heavily inspired by VQmod.
An ocmod file searches a string and replaces it with a modified version. It can also add code. It is installed using the extension installer and on refresh it creates a new file in the system/modification folder with the same folder structure as the core.
An upgrade of the shop will retain all changes on the premise that the search string is still there for starters

It works great but EVENTually it might be replaced by the event system which can add to/alter the core with a hook system like Wordpress eg.
https://github.com/opencart/opencart/wi ... ion-System
https://github.com/vqmod/vqmod/wiki
https://github.com/opencart/opencart/wi ... s)-2.0.0.1
Unfortunately I find myself writing ocmods for every single opencart (sub)version which makes it kinda developer unfriendly.
I've written WP plugins for 3.6 that still work on 4.4

But OC is still the best for its speed and ease of use!
I'll give you an example for the logo using ocmod later today.
Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
Tips:
- Always search for one unique line and add/replace to your liking. You can specify which occurrence to use if there are multiple hits for the search. Use <search index="x"... where x is the nth occurrence starting from 0.
- array $data keys are extracted, so $data['something'] is used as $something in the tpl.
- You can upload this file directly to the system folder and it'll work. Handy for quick changes to the ocmod.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Logo in Footer</name>
<code>unique-code-1</code>
<version>1.0</version>
<author>your name</author>
<link>http://www.yourdomain.com</link>
<!--prepare data-->
<file path="catalog/controller/common/footer.php">
<operation>
<search><![CDATA[$this->load->language('common/footer');]]></search>
<add position="after"><![CDATA[
if ($this->request->server['HTTPS']) {
$server = $this->config->get('config_ssl');
} else {
$server = $this->config->get('config_url');
}
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
$data['logo'] = $server . 'image/' . $this->config->get('config_logo');
} else {
$data['logo'] = '';
}]]></add>
</operation>
</file>
<!--use data-->
<file path="catalog/view/theme/*/template/common/footer.tpl">
<operation>
<search><![CDATA[<p><?php echo $powered; ?></p>]]></search>
<add position="after"><![CDATA[<div class="pull-right"><img src="<?php echo $logo; ?>" alt="logo" title="store name"></div>]]></add>
</operation>
</file>
</modification>
Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
Thank you

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
Hiya artcore,artcore wrote:Just as an example.
Tips:
- Always search for one unique line and add/replace to your liking. You can specify which occurrence to use if there are multiple hits for the search. Use <search index="x"... where x is the nth occurrence starting from 0.
How would you make multiple changes in one file
For example:
In catalog/controller/module/category.php you have the following code listed twice
Code: Select all
'name' => $child['name'] ,......more code...
thanks in advance and sorry to hijack the thread
It's related so fine by me

If you want all occurences to be changed leave out the index on the search tag, otherwise use index="0,3" for example to change the first and fourth.
Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
Code: Select all
<file path="catalog/controller/product/search.php">
<operation info="Your description">
<search index="0">
<![CDATA[
foreach ($results as $result) {
]]>
</search>
<add position="before">
<![CDATA[
$your_new_code here ...
]]>
</add>
</operation>
<operation info="Infotext 2">
<search index="0">
<![CDATA[
$data['products'][] = array(
]]>
</search>
<add position="after">
<![CDATA[
'my_new_var' => $this->url->link( 'product/product', 'product_id=' . $result['product_id'] . $url ),
]]>
</add>
</operation>
</file>
Code: Select all
<search index="1,3">
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Users browsing this forum: No registered users and 8 guests