Support Forums

Smarty {if} code not always showing up in some browers?

This is a discussion on Smarty {if} code not always showing up in some browers? within the Technical Support forums, part of the Technical Support Forums category; I added the login box to my layout.tpl template so that when someone not logged in arrives (guest) they see ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 10-10-2008, 11:42 PM   #1
Junior Member
 
Join Date: Mar 2008
Posts: 12
Rep Power: 15
forumosa is on a distinguished road
Unhappy Smarty {if} code not always showing up in some browers?

I added the login box to my layout.tpl template so that when someone not logged in arrives (guest) they see a login form in the upper right corner, but after they log in, the will see links to PM box and some navigation

The logic looks like this:
Code:
{if $smarty.session.username<>'' || $smarty.cookies.username<>""}
	{if $pmon=="Y"}
		{$smarty.const.LANG_USER_WELCOME} <a href="{$smarty.const.URL}/userindex.php" TITLE="Click your name to see Account Home" ALT="Click your name to see Account Home">{$smarty.session.username}</a>
		({$unreadpms} new out of <a href="{$smarty.const.URLS}/private.php">{$totalpms} PMs</a>)
		<BR />
		<a href="{$smarty.const.URL}/search.php">SEARCH</a> 
		{if $canSaveFavorites=="Y"}
			<a href="{$smarty.const.URLS}/userfavorites.php">FAVORITES</a>
		{/if}
		<a href="{$smarty.const.URLS}/userbrowselistings.php">MANAGE</a>
		<a href="{$smarty.const.URLS}/logout.php">LOGOUT</a>
	{else}
	<form action="login.php" name="login" method="post" onsubmit="return checkform(this)">
		<input name="username" type="text"     class="navusername" tabindex="1" value="Seller ID" onFocus="if(this.value=='Seller ID')this.value='';"/> 
		<input name="password" type="password" class="navpassword" tabindex="2" value="Password" onFocus="if(this.value=='Password')this.value='';"/>
		<BR />
		<input name="remember" type="checkbox" class="navlogin"    value="Y" tabindex="3" />
		<input name="submit" type="submit" id="submit" class="navlogin" value="Login" "{$smarty.const.LANG_SUBMIT}" tabindex="4" />
		<input name="action" type="hidden" id="action" value="login" />
		<input name="from"   type="hidden" id="from" value="{$from}" />
		<input name="goto"   type="hidden" value="{$smarty.get.goto|escape:'url'}" />
		or <a href="{$smarty.const.URLS}/userjoin.php">{$smarty.const.LANG_USER_REGISTER}</a>
	</form>
	{/if}
{/if}
This seems to work if I'm looking at the website in Google Chrome, but not in Firefox, Safari or IE7. In Chrome, when I visit the site when I am not logged in, I see the login form. But in the other browsers, nothing is displayed and when I View Source in those 3 browsers, there is nothing ther). It is as if the 3 other browsers ignore everything between {else} and the first {/if}

Now after I log in, all 3 browsers show the navigation links: stuff between {if $pmon=="Y"} and {else}

Why would this be?
And how can I address this?
Is it a cookie problem?


I was using smarty code in my showlistings to show some listing data there. Like:
Code:
{if $sDisCity == "Y"}
	<td{if $entry.class<>""} class="{$entry.class}"{/if}>{$entry.city}
{/if}
But I removed the logic because information that was there was not showing up in FF3.0.3, IE7 or Safari3.1.2 (but was showing up splendidly in Chrome)

NOTE: I've been using Chrome a lot these days as a primary browser
forumosa is offline  
Old 10-11-2008, 12:06 AM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

From your code it appears to be a cookie / logged in issue. The browser wouldn't matter.

You have one if statement wrapped around it:
{if $smarty.session.username<>'' || $smarty.cookies.username<>""}

So if they are not logged in then nothing inside that if is going to show.

What I think you need is:

Code:
{if $smarty.session.username<>'' || $smarty.cookies.username<>""}
//logged in
{$smarty.const.LANG_USER_WELCOME} <a href="{$smarty.const.URL}/userindex.php" TITLE="Click your name to see Account Home" ALT="Click your name to see Account Home">{$smarty.session.username}</a>
   {if $pmon}
({$unreadpms} new out of <a href="{$smarty.const.URLS}/private.php">{$totalpms} PMs</a>)
   {/if}
   .. rest of logged in code.
{else}
//note logged in show the login form.
{/if}
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 10-11-2008, 12:06 AM   #3
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

by the way how are you liking Google Chrome? I am still waiting on the mac version.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 10-11-2008, 03:01 AM   #4
Junior Member
 
Join Date: Mar 2008
Posts: 12
Rep Power: 15
forumosa is on a distinguished road
Cool Thank you!

Thanks!

So far, I am liking Google Chrome on my Windows machine - very smooth transition for me from FF. Is very fast, and I like how it maximizes on the desktop

I use Firefox on a LinuxMint notebook, but I'm finding myself on the Windows machine these days because I am so used to making websites using old Windows based apps. It's too bad I need to be mindful of cross-browser compatibility again
forumosa is offline  
Closed Thread

Tags
browsers , smarty

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
images not showing up/ ad listings not showing up anna245 Technical Support 4 04-19-2008 09:56 AM
Smarty TPL and Rotations xanthari Templates, HTML, CSS, and Design Help 1 07-20-2006 04:02 PM


All times are GMT -4. The time now is 04:31 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0