Menu

#2 problem w/ 'if' operation on an object property

open
nobody
None
5
2004-09-08
2004-09-08
Anonymous
No

email: rich@corticaldesignDOTcom

smarty calls (php):
-------------------------------------------------
//assume some class

class code (UserManager)

class UserManager
{
var $loggedIn;
..
//constructor
function UserManager()
{
..
//set $loggedIn at some point(boolean)
..
}
}

//fire up smarty
$smarty = new Smarty();
$smarty->template_dir = $smartyTemplateDir;
$smarty->compile_dir = $smartyCompileDir;
$smarty->config_dir = $smartyConfigDir;
$smarty->cache_dir = $smartyCacheDir;
$smarty->register_object("user", $UserManager);
$smarty->display('index.tpl');

template code (index.tpl):

... template code
{if user->loggedIn eq true}
Welcome, {$user->id}<br />
<a href = 'logout/'>Logout</a>

{else}
<form method='post' action='login/'>
<p>Name:<input type='text' name='username'
class='' /></p>
<p>Password:<input type='text'
name='password' class='' /></p>
<input type='submit' name='submit'
value='login' />
</form>
{/if}
... template code

When trying to do this, PHP generates an error:

parse error, unexpected '>' in C:\program files\apache
group\apache\htdocs\BFD2
\includes\smarty\templates_c\%%45^45E^45E480CD%%
index.tpl.php

offending line in this file is as follows:

<?php if (user - > loggedIn == true): ?>

(note space between '-' and '>' in the parsed template
file)

Cheers!! :-)

Discussion

MongoDB Logo MongoDB