So if the theme was called "blue" the image source would automatically become "/catalog/view/theme/blue/image/" etc.
It would be handy for the stylesheet too which is hard coded to "catalog/view/theme/default/stylesheet/"
I'm new to Opencart so I apologise if this either been covered or does not make any sense.
Ozzy
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Your "<?php echo $this->directory; ?>" was introduced in 0.7.8, around September/October last year, not a year ago!Qphoria wrote:Looks like there's pretty much a years worth of fixes missing from 1.x
And while that method may work in 0.x, where the "layout.tpl" is at the top level of the template directory, it doesn't work in 1.x, because "layout.tpl" is in "catalog/view/theme/default//template/module" and that is the directory that would be referred to by "$this->directory".
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
SILENCE! If you check the 0.x forums you will see it was introduced on March 11th 2008:fido-x wrote: Your "<?php echo $this->directory; ?>" was introduced in 0.7.8, around September/October last year, not a year ago!
http://forum.opencart0.com/index.php/topic,1002.0.html
1 year! Game. Set. Match!

Certainly there will be some syntax changes, but the method will still likely applyfido-x wrote: And while that method may work in 0.x, where the "layout.tpl" is at the top level of the template directory, it doesn't work in 1.x, because "layout.tpl" is in "catalog/view/theme/default//template/module" and that is the directory that would be referred to by "$this->directory".
Sure, it was mentioned on the forum a year ago as a modification, but not introduced into the core until the 0.7.8 release! My comment stands!Qphoria wrote:SILENCE! If you check the 0.x forums you will see it was introduced on March 11th 2008:fido-x wrote: Your "<?php echo $this->directory; ?>" was introduced in 0.7.8, around September/October last year, not a year ago!
http://forum.opencart0.com/index.php/topic,1002.0.html
1 year! Game. Set. Match!![]()
Hadn't thought of that one! A lot easier than the method I used.Qphoria wrote:Edit your tpl files and change "default" to <?php echo $this->template; ?>
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Just tried this and it doesn't work! This sort of code may work where the layout.tpl file is at the top level of the template directory, but doesn't work when the layout.tpl file is 2 subdirectories down.Qphoria wrote:Sure enough.
Edit your tpl files and change "default" to <?php echo $this->template; ?>
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
<?php echo $this->template; ?> = "default/template/module/layout.tpl"
so I guess you'd need to parse that first to get just the "default" off of it.
It works on the principal in the controller files:
$this->template = $this->config->get('config_template') . 'module/xxx.tpl';
So replace default with <?php echo ($x = explode($this->template, '/')) ? '$x[0]' : 'default' ?>
It was in the svn shortly after that time, so it WAS in the corefido-x wrote: Sure, it was mentioned on the forum a year ago as a modification, but not introduced into the core until the 0.7.8 release! My comment stands!

Edit all tpl files
replace default with:
Code: Select all
<?php $tpl = explode('/', $this->template); echo (isset($tpl[0])) ? $tpl[0] : 'default' ?>
Code: Select all
$this->data['template_name'] = (reset(explode('/', $this->config->get('config_template'))));
Code: Select all
<?php echo $template_name; ?>
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
fido-x wrote:Similar to the method I used. What I did, was place the following in the relevant controllers:then replaced references to default in the template files to:Code: Select all
$this->data['template_name'] = (reset(explode('/', $this->config->get('config_template'))));
Yes, I know I don't have to use "reset" in the "explode" function. It just guarantees that I get the first value from the resulting array.Code: Select all
<?php echo $template_name; ?>
Yea that's fine too.. tho my way only edits the tpl files, less leg work

You're right there. Shouldn't really modify the controllers for this type of thing anyway.Qphoria wrote:.. tho my way only edits the tpl files, less leg work
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
- everything in "catalog/view/theme/default/template/module"; and
everything in "catalog/view/theme/default/template/product".
You can use either Q's code:
Code: Select all
<?php $tpl = explode('/', $this->template); echo (isset($tpl[0])) ? $tpl[0] : 'default' ?>
Code: Select all
<?php $tpl = explode('/', $this->template); echo $tpl[0]; ?>
If the template from the settings table doesn't exist anymore (for some reason), your display will be stuffed up. Mind you, having a fallback for the default template will only work if the default template is still there and still called "default".
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Code: Select all
<?php echo reset(explode('/', $this->template)); ?>

Good one! I'll include that in the next update to my modsQphoria wrote:Could even use your reset option without a fallback for a really short one:
Code: Select all
<?php echo reset(explode('/', $this->template)); ?>

Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Users browsing this forum: No registered users and 4 guests