|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
terra Smarty Rookie
Joined: 27 Jul 2011 Posts: 26
|
Posted: Wed Mar 20, 2013 2:24 am Post subject: how to call the code below in TPL? |
|
|
hi,
how to call the code below in TPL?
Quote: | if( isset( $_SESSION["minhalista"][$id]) == $id ){
echo '
<div class="festa">
id: '.$id.'<a href="#" class="add selecionado" rel="'.$id.'" nm="'.$nome.'">Selecionado</a>
</div>
';
}else{
echo '
<div class="festa">
id: '.$id.'<a href="salva.php?id='.$id.'&acao=add" class="add selecionar" rel="'.$id.'" nm="'.$nome.'" nm2="'.$preco.'">Selecionar</a>
</div>
';
}
} |
Thanks[/quote] |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 20, 2013 2:45 pm Post subject: |
|
|
This doesn't make much sense:
Code: | if( isset( $_SESSION["minhalista"][$id]) == $id ) |
isset() returns true or false, testing if that equals an $id is probably not what you want. maybe:
Code: | if(isset($_SESSION["minhalista"][$id]) && $_SESSION["minhalista"][$id] == $id) |
That said, you can do this in a template:
Code: | {if isset( $smarty.session.minhalista.$id ) && $smarty.session.minhalista.$id == $id }
<div class="festa">
id: {$id}<a href="#" class="add selecionado" rel="{$id}" nm="{$nome}">Selecionado</a>
</div>
{else}
<div class="festa">
id: {$id}<a href="salva.php?id={$id}&acao=add" class="add selecionar" rel="{$id}" nm="{$nome}" nm2="{$preco}">Selecionar</a>
</div>
{/if} |
make sure $id, $nome and $preco are assigned as smarty variables. |
|
Back to top |
|
terra Smarty Rookie
Joined: 27 Jul 2011 Posts: 26
|
Posted: Wed Mar 20, 2013 6:16 pm Post subject: |
|
|
Hi,
thanks.
He takes the record id session in the php, but not caught by smarty, what could be wrong?
Quote: |
in tpl
{foreach from=$var_list item=i}
in php
$var_list[$i]['id']=$row['business_id'];
|
I appreciate any help
Thanks again |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 20, 2013 7:01 pm Post subject: |
|
|
not sure what that means. you might want to explicitly assign the record id to a smarty variable instead of trying to access the session from smarty. |
|
Back to top |
|
terra Smarty Rookie
Joined: 27 Jul 2011 Posts: 26
|
Posted: Wed Mar 20, 2013 7:18 pm Post subject: |
|
|
Hi,
see
Quote: | {if isset( $smarty.session.minhalista.$id ) && $smarty.session.minhalista.$id == $i.id }
<div class="festa">
id: {$i.id}<a href="#" class="add selecionado" rel="{$i.id}" >Selecionado</a>
</div>
{else}
<div class="festa">
id: {$i.id}<a href="salva.php?id={$i.id}&acao=add" class="add selecionar" rel="{$i.id}" >Selecionar</a>
</div>
{/if} |
i can help me?
Thanks |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|