View previous topic :: View next topic |
Author |
Message |
whatshakin Smarty n00b
Joined: 24 Sep 2009 Posts: 3
|
Posted: Thu Sep 24, 2009 2:13 pm Post subject: {if} {else} help |
|
|
I want to be able to show different content on the index page than the other pages. Is there an {if}{else} statement i can use to either include div's containing pictures or some modules based on the url? or is there another way?
Last edited by whatshakin on Thu Sep 24, 2009 3:31 pm; edited 1 time in total |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Sep 24, 2009 3:13 pm Post subject: |
|
|
does the urlExists plugin exist? If you have a value in $urlExists var, you can test it:
Code: | {if !empty($urlExists)} |
Code: | {if $urlExists ne ""} |
By "url exists", I assume you are asking does the URL variable have a value, and not if the URL is a real web page. You don't want to add networking tests in-template. |
|
Back to top |
|
whatshakin Smarty n00b
Joined: 24 Sep 2009 Posts: 3
|
Posted: Thu Sep 24, 2009 3:30 pm Post subject: Lost |
|
|
You can disregard what i posted there...i really have no idea what to do.
What i want to do is figure out how to get the current url and if it's home.php than display one thing. If it's anything different like: home.php?cat=278 than I would like something different displayed.
thanks |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Sep 24, 2009 4:47 pm Post subject: |
|
|
You could do:
Code: | {if !empty($smarty.get.cat)}
{* there is a cat in the url, do something *}
...
{/if} |
|
|
Back to top |
|
whatshakin Smarty n00b
Joined: 24 Sep 2009 Posts: 3
|
Posted: Thu Sep 24, 2009 5:23 pm Post subject: Solution |
|
|
I found a plugin called currenturl. I installed it and used this code to display different content on the homepage than on the rest of the pages.
Works perfectly.
Code: | {currenturl var=currenturl}
{if $currenturl eq 'http://www.grebitus.us/home.php'}
<div class="right_image1">
<img src="skin1/images/home_right1.jpg" alt="" />
</div>
<div class="right_image2">
<img src="skin1/images/home_right2.jpg" alt="" />
</div>
{elseif $currenturl eq 'http://www.grebitus.us/'}
<div class="right_image1">
<img src="skin1/images/home_right1.jpg" alt="" />
</div>
<div class="right_image2">
<img src="skin1/images/home_right2.jpg" alt="" />
</div>
{else}
{include file="customer/menu_cart.tpl" }
{include file="modules/Bestsellers/menu_bestsellers.tpl" }
{/if} |
|
|
Back to top |
|
jpiercemaine Smarty Regular
Joined: 24 Sep 2009 Posts: 82
|
Posted: Fri Sep 25, 2009 7:11 pm Post subject: Handle it in php |
|
|
I know this is a smarty forum but why wouldn't you set a variable equal to the parameter passed. Then based on the variable you could set the content.
PHP:
Code: |
$params=$_GET;
$category=$params["cat"];
$smarty->assign_by_ref("Category", $category);
|
Smarty:
Code: |
{if $Category==1}
show this
{elseif $Category==2}
show that
{/if}
|
[/code] |
|
Back to top |
|
jonemere Smarty n00b
Joined: 04 Jan 2010 Posts: 3
|
Posted: Wed Jan 06, 2010 9:33 am Post subject: |
|
|
Nice code man. It is very helpful to me. Nice information.
Thanks _________________ 2.5 hdd |
|
Back to top |
|
|