X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   $main variable... where is it, and how can I use it? (https://forum.x-cart.com/showthread.php?t=25865)

fogelka 10-16-2006 08:18 PM

$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.

wjbrewer 10-16-2006 08:25 PM

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"}

Jon 10-16-2006 08:31 PM

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.

fogelka 10-16-2006 08:47 PM

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!


All times are GMT -8. The time now is 06:52 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.