Post by huhitschris » Mon Dec 28, 2009 5:35 am

Most template files have references to the "default" theme folder for images, however if I want to create a new template I have to modify many of these references to point to the new theme directory. Also, if I change the name of the directory for any reason, I have to go through these references all over again.

How about setting up a variable available to every template file which contains the current theme name or the current theme directory...

So,
<img src="catalog/view/theme/default/image/...">
Could be:
<img src="catalog/view/<?php echo $theme;?>/default/image/...">
Or even easier, a variable containing the path to the theme's image folder:
<img src="<?php echo $theme_image;?>/...">
WordPress does something like this with the bloginfo() function to retrieve a ton of info which makes theme development much easier for designers and developers.

This would save time and make building OC templates much easier.

What do you guys think?

PM me for custom OpenCart template design and development.


New member

Posts

Joined
Wed Aug 19, 2009 3:12 pm

Post by Aco » Fri Oct 07, 2011 1:34 pm

I think that sounds like a great idea - finding it frustrating at the moment having to keep adding in that long path!...

Aco
Newbie

Posts

Joined
Fri Sep 09, 2011 2:08 pm
Location - UK

Post by Xsecrets » Fri Oct 07, 2011 1:41 pm

try

Code: Select all

<img src="catalog/view/theme/<?php echo $this->config->get('config_template'); ?>/image/...">

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Aco » Fri Oct 07, 2011 1:46 pm

Wow - that was fast!
I did just come across this in another thread, although it actually ends up being more code that just typing out the theme name.

What would be ideal would be a variable that included the overall theme path, something like:

Code: Select all

<img src="<?=$this->config->get('theme_path')?>/image/my-image.jpg" />

Aco
Newbie

Posts

Joined
Fri Sep 09, 2011 2:08 pm
Location - UK

Post by otley » Tue May 14, 2013 4:02 pm

Put this on the top of your header.tpl

<?php
define('THEME', $this->config->get('theme_path'));
echo THEME;
?>

And now you can use that everywhere in your theme.

Newbie

Posts

Joined
Tue May 14, 2013 4:01 pm

Post by punitkorat » Sun Jun 26, 2016 1:10 pm

Hello,

Is it possible with opencart newer versions (Opencart 2.2.x)??

It is not working with my website.


thank you.

Newbie

Posts

Joined
Sun Jun 26, 2016 1:06 pm
Who is online

Users browsing this forum: No registered users and 63 guests