Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

$main variable... where is it, and how can I use it?
 
Reply
   X-Cart forums > X-Cart 4 > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-16-2006, 08:18 PM
 
fogelka fogelka is offline
 

Advanced Member
  
Join Date: Jun 2006
Posts: 83
 

Default $main variable... where is it, and how can I use it?

I am trying to find a way to tell xCart to open home.tpl with one header or another, based on which page I'm linking in to. I described my problem here: http://forum.x-cart.com/showthread.php?t=25821

I'm not getting any replies on that thread, so striking out on my own, one of my ideas is to use $main to determine what kind of page I linked to, and then use that in an {if} statement to select which header, column format, etc, to use.

Can someone tell me how to use $main ? Where is it, how do I read it, and where does it get its value? Can I define other values that it can take?

Thanks.
__________________
xcart v4.0.18 [linux]

Loyalty Points, DSEFU, Easy Checkout, Featured Product Manager, Remember Me, Relevant Search, Vertical Flyouts, Multiple Category Templates. Loads of other tweaks and mods learned in forums.
Reply With Quote
  #2  
Old 10-16-2006, 08:25 PM
  wjbrewer's Avatar 
wjbrewer wjbrewer is offline
Banned
 

X-Adept
  
Join Date: Feb 2005
Location: Pittsburgh, PA
Posts: 504
 

Default Re: $main variable... where is it, and how can I use it?

$main is a smarty variable that is assigned in a PHP file. For example...your product.php page has a variable of 'product'. Look for this in the PHP file

PHP Code:
$main "product";
$smarty->assign("main",$main); 

or

PHP Code:
$smarty->assign ("main""product"); 

You can then use an {if} {else} statement to load different templates.

For example:

HTML Code:
{if $main eq 'product'} {include file="skin1/customer/main/product.tpl"} {else} {include file="skin1/different.tpl"}
Reply With Quote
  #3  
Old 10-16-2006, 08:31 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,175
 

Default Re: $main variable... where is it, and how can I use it?

The $main variable is set in various places depending on which file/page is being called. $main is aptly named because it determines what content is displayed in the main content area.

In it's basic form, a php file assigns a $main variable to smarty in the form:

Code:
$smarty->assign("main","something");

This main variable is then read in skin1/customer/home_main.tpl in the form:

Code:
{elseif $main eq "something"} {include file="somefolder/something.tpl"}

somefolder/something.tpl is then a file that displays the content in the main area.

You can use the $main variable in your skin1/customer/home.tpl (or elsewhere) to use distinguishing headers in the form:

Code:
{if $main eq "something"} Show This {else} No Show This {/if}

Hope this helps.
__________________
|
Our clients strive to be the best in their industry.
We position you for success with our strategically integrated approach to software, search engine optimization and social media.

E-COMMERCE FUTURE
https://www.stackdigital.com

LINKEDIN
https://www.linkedin.com/in/smackdigital
Reply With Quote
  #4  
Old 10-16-2006, 08:47 PM
 
fogelka fogelka is offline
 

Advanced Member
  
Join Date: Jun 2006
Posts: 83
 

Default Re: $main variable... where is it, and how can I use it?

Thanks, gentlemen. This is exactly what I needed.

Not only that, but I get to see it in two different "translations", which makes it crystal clear for me, a rank newb!
__________________
xcart v4.0.18 [linux]

Loyalty Points, DSEFU, Easy Checkout, Featured Product Manager, Remember Me, Relevant Search, Vertical Flyouts, Multiple Category Templates. Loads of other tweaks and mods learned in forums.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:05 PM.

   

 
X-Cart forums © 2001-2020