Simple IF statement Help

For my index page I would like to include a file other than main.tpl so I need to write a simple if statement that checks for the index page, if true loads new.tpl, if false loads main.tpl.



I believe it would look something like this but I don’t know how to check for the index page…


<br />
{if [I]page=index[/I]}<br />
		{include file="main.tpl"}<br />
    {else}<br />
    	{include file="new.tpl"}<br />
    <br />
    {/if}<br />

```<br />
<br />
Can anyone help me with this statement please? Thanks!

A simple if?

Is that not simple?



Figured there would be some kind of variable for current page or something I don’t know?

[url]Search Results for "docsv2" | Smarty

I don’t think that is what I’m looking for. I’m looking for a way to check the current page being viewed. The bold values is what I think i need. If they even exist…


{if [B]$current_page[/B]==[B]index.php[/B]}

I believe the smarty engine requires single quotes around strings in an if statement.



[url]Search Results for "docsv2" | Smarty

ok so it would look something like this



{if $current_page == 'index.php'}
{include file="new.tpl"}
{else}
{include file="main.tpl"}
{/if}




But what I’m really trying to figure out is if there is some kind of built in variable like $current_page. I just made that up for demostration purposes. Or maybe that is something I have to define myself?

I beleive it is $current_url



Turn on the Debugging Console and then you can see all the variable values when a page loads.



David


{if $config.current_url == 'index.php'}

Yeah you are right its $current_url.



I tried this but it’s not working.



{if $current_url == 'index.php'}
{include file="new.tpl"}
{else}
{include file="main.tpl"}
{/if}




The else statement is always executed. I tried inserting just the variable {$current_url} into the page to see if it would output something but It didn’t. Can someone maybe steer me in the right direction? Thanks.

Thanks baballuci! I didn’t see your post earlier. That works.

you can also use:


{if $mode == 'index'}
{include file="main-1.tpl"}
{elseif $mode == 'products'}
{include file="main-2.tpl"}
{elseif $mode == 'categories'}
{include file="main-3.tpl"}
{elseif $mode == 'cart'}
{include file="main-4.tpl"}
{elseif $mode == 'checkout'}
{include file="main-5.tpl"}
{else}
{include file="main-6.tpl"}
{/if}


ect…

What about mode search controler search.php?

Also: if home page in 2.0.6.

Thank you.



QUOTE=snorocket;56888]you can also use:
{if $mode == 'index'}
{include file="main-1.tpl"}
{elseif $mode == 'products'}
{include file="main-2.tpl"}
{elseif $mode == 'categories'}
{include file="main-3.tpl"}
{elseif $mode == 'cart'}
{include file="main-4.tpl"}
{elseif $mode == 'checkout'}
{include file="main-5.tpl"}
{else}
{include file="main-6.tpl"}
{/if}
ect...[/QUOTE]