Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Variable used in more templates, how?? 
 
kla0005
Member
 
Total Posts:  43
Joined:  2011-10-05
 

Hey Guys!

I was wondering.. Is it possible / if yes, how? - To make a “kinda” global variable?

See, I have to templates.. frontpage.phtml and sidebar.phtml, right?
I want to set a variable in frontpage.phtml that I want to use inside sidebar.phtml - I want to set the value inside the frontpage and then grab the value in sidebar.

My possible way would be a simple $_SESSION variable, but I was hoping for something more simple?

Is there a way to make this in Magento?

Thanks!

- Jonatan
Happy New Year!

 
Magento Community Magento Community
Magento Community
Magento Community
 
satish
Enthusiast
 
Total Posts:  812
Joined:  2008-03-24
34,mantri Sadan,Shivaji Nagar,Nagpur,MS,India 4400
 

use variable is ‘var1’. To fetch the newly registered variable, we will use the following code:
Mage::registry(’var1’);

$value=’some value’;

Mage::register(’var1’, $value);

in short use set and get registry in Magento

Satish

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top