I want to use a variable for my image path.
And that variable will be called from whereever an image exists; layout.tpl, header.tpl, footer.tpl and home.tpl
so where and how can i declare something like this:
$this->data['img_path'] = 'catalog/view/theme/default/images/';
so i can load images in templates like this:
<img src="<?php echo $img_path; ?>logo.png" width="343" height="100" alt="logo" />
Thanks a lot.
And that variable will be called from whereever an image exists; layout.tpl, header.tpl, footer.tpl and home.tpl
so where and how can i declare something like this:
$this->data['img_path'] = 'catalog/view/theme/default/images/';
so i can load images in templates like this:
<img src="<?php echo $img_path; ?>logo.png" width="343" height="100" alt="logo" />
Thanks a lot.
you can use
Code: Select all
<img src="<?php echo DIR_TEMPLATE; ?>default/image/logo.png" width="343" height="100" alt="logo" />
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
thanks for the reply.readyman wrote:you can useCode: Select all
<img src="<?php echo DIR_TEMPLATE; ?>default/image/logo.png" width="343" height="100" alt="logo" />
But what if i want to declare as image path diffrent than DIR_TEMPLATE .
I mean is there a way to declare a global template variable where can i call from every tpl file without redeclaring this variable in each templates' controller?
Yeah, make another global variable in the config.php file - call it anything you like.
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
thanks again, and of course that works.readyman wrote:Yeah, make another global variable in the config.php file - call it anything you like.
But i want to change image path according to selected language.
I mean, i need to declare an image path variable that is global for all template files, and i i need to declare it in the business logic.
So I can determine the path according to the selected language.
Or i will declare as constant in the config, which i cant change according to other variables,
or i will declare it in every controller again and again, because it will be called from every .tpl file.
I sort of know what you mean, but I can't get my head around it... especially when you mentioned the language part.
Can you post a few working examples of where you have found the need for this variable used in relation to the language and I'll see if I can pinpoint which files you need to be updating. I'm pretty sure they'll be in the main library files - library/language.php maybe?
@Quphoria - thanks
Can you post a few working examples of where you have found the need for this variable used in relation to the language and I'll see if I can pinpoint which files you need to be updating. I'm pretty sure they'll be in the main library files - library/language.php maybe?
@Quphoria - thanks
http://www.alreadymade.com
Follow me on twitter.com/alreadymade
I'd go into the session with this:
system/library/customer.php and just add thisTo make sure the session data is destroyed when logging of I add
line~120
Anywhere in your template you can now useand since you can use the default Session Vars you can build your custom path likeresulting in "to/your/dir/en"
Quick and available in any template ;-)
system/library/customer.php and just add this
Code: Select all
### AddedHack: get something in the Session on login
$this->session->data['myAddedSessVar__imgPath'] = 'to/your/dir/';
line~120
Code: Select all
### AddedHack: do a session destroy on logout
session_destroy()
Code: Select all
$this->session->data['myAddedSessVar__imgPath']
Code: Select all
$this->session->data['myAddedSessVar__imgPath'].$this->session->data['language']
Quick and available in any template ;-)
Hi every one ... im sorry for interrupting,
but no one replays my post
and i think here is the most related post
of how to add price in my title like this:
<title><?php echo $title, $price; ?></title>
the $title works but after that goes message "Undefined variable: product in <b>/myweb.com/catalog/view/theme/mytheme/template/common/header.tpl</b> on line <b>22</b> "
can some one help me please?
but no one replays my post
and i think here is the most related post
of how to add price in my title like this:
<title><?php echo $title, $price; ?></title>
the $title works but after that goes message "Undefined variable: product in <b>/myweb.com/catalog/view/theme/mytheme/template/common/header.tpl</b> on line <b>22</b> "
can some one help me please?
Who is online
Users browsing this forum: Amazon [Bot] and 3 guests