[PHPTAL] Tal:condition question

2011-07-13 Thread Teis Lindemark
Hi,

 

I am sitting with a page where I have a menu where the design is defined as
a macro. In this menu, I want to have one of the elements that is Login or
Logout depends on the user is logged in or logged out.

 

So I was thinking that tal:condition could do this for me. I have a function
that I can check if is true or false (true if you are logged in), but don't
get it right when I should use it with the tal:condition.

 

lia. href=. tal:condition=.?...Login/a

 

My function that I usually check is $l-IsLoggedIn() that is accesable from
all the webpage.

 

Do someone have an idea how I can do this as best as possible?

 

Hope for an answer.

 

Teis

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Tal:condition question

2011-07-13 Thread sean
Thank you for contacting Canterris.  I???m currently out of the office until 
July 25.  Please feel free to contact Will Freemen (w...@canterris.com) or 
Canterris Technical Support (supp...@canterris.com) for any support requests.

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: Re: [PHPTAL] Tal:condition question

2011-07-13 Thread sean
Thank you for contacting Canterris.  I???m currently out of the office until 
July 25.  Please feel free to contact Will Freemen (w...@canterris.com) or 
Canterris Technical Support (supp...@canterris.com) for any support requests.

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


SV: [PHPTAL] Tal:condition question

2011-07-13 Thread Teis Lindemark
Hi,

 

Thanks for your quick answer.

 

Teis

 

Fra: phptal-boun...@lists.motion-twin.com
[mailto:phptal-boun...@lists.motion-twin.com] På vegne av Marco Pivetta
Sendt: 13. juli 2011 09:25
Til: Template Attribute Language for PHP
Emne: Re: [PHPTAL] Tal:condition question

 

Supposing that you've set variable l in your template, you can just write

li
a href=... tal:condition=l/isLoggedIn()Logout/a
a href=... tal:condition=not:l/isLoggedIn()Login/a
/li

That will do :)

Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com




On 13 July 2011 09:21, Teis Lindemark m...@teilin.net wrote:

Hi,

 

I am sitting with a page where I have a menu where the design is defined as
a macro. In this menu, I want to have one of the elements that is “Login” or
“Logout” depends on the user is logged in or logged out.

 

So I was thinking that tal:condition could do this for me. I have a function
that I can check if is true or false (true if you are logged in), but don’t
get it right when I should use it with the tal:condition.

 

lia… href=”…” tal:condition=”…?...”Login/a

 

My function that I usually check is $l-IsLoggedIn() that is accesable from
all the webpage.

 

Do someone have an idea how I can do this as best as possible?

 

Hope for an answer.

 

Teis


___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

 

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: SV: [PHPTAL] Tal:condition question

2011-07-13 Thread sean
Thank you for contacting Canterris.  I???m currently out of the office until 
July 25.  Please feel free to contact Will Freemen (w...@canterris.com) or 
Canterris Technical Support (supp...@canterris.com) for any support requests.

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


[PHPTAL] tal:attributes and checkboxes

2011-07-13 Thread Teis Lindemark
Hi,

The website I am working on now has a list where the user should click on a
checkbox and then have then could check the items the user want and this
should be used later.

When I started doing this, I created the the checkbox like this: input
type=checkbox name=favorite value=${offers/idoffer}
OnCheckedChanged=submit(); onclick=if(this.checked)
this.form.submit();/

Then I was thinking that I should place this in a array that I so place in a
session variable, so when the page here refresh, the item is still checked
and I also have access to the favorites later in the process.

This is the code in the php file that create the array and that I place in
the session vaiable:
isset($_SESSION['fav']) ? $_SESSION['fav'] : $_SESSION['fav'] = null;
if(isset($_GET['submit'])  $_GET['submit'] == 'fav') {
if(count($_SESSION['fav'])  5) {
$_SESSION['fav'][] = array(idoffer = $_POST['favorite'],
checked = true);
}
$tmp = Array();
foreach($_SESSION['fav'] as $f) {
$tmp[$f['idoffer']][] = $f['checked'];
}
$_SESSION['fav'] = $tmp;
unset($tmp);
}

Now I was thinking to use tal:attributes=checked x something like that to
be sure that it the item is checked after the checking submit the form.

Is this totally wrong way to get my idea to work?

Hope anyone can help me with this one.

Teis



___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] tal:attributes and checkboxes

2011-07-13 Thread sean
Thank you for contacting Canterris.  I???m currently out of the office until 
July 25.  Please feel free to contact Will Freemen (w...@canterris.com) or 
Canterris Technical Support (supp...@canterris.com) for any support requests.

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal