Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

problem used Eval

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Help Wanted (commercial)
View previous topic :: View next topic  
Author Message
MAHMOOD
Smarty n00b


Joined: 23 Jun 2013
Posts: 4

PostPosted: Sun Jun 23, 2013 12:27 pm    Post subject: problem used Eval Reply with quote

hello

I'm porgram the block with php code and insert the database but eval not work

Code:
         <td width="17%" valign="top">{foreach name="main" from=$block item="info"}
{if not $smarty.foreach.last and $smarty.foreach.cats.iteration is div by 1}
<table class="right" border="0" width="50%" cellspacing="0" cellpadding="0">
   <tr>
      <td id="blockh" width="85">{$info.name_block}</td>
   </tr>
   <tr>
      <td id="blockm" width="85">{eval var=$info.textblock }</td>
   </tr>
</table>
{/if}
{/foreach}
Back to top
View user's profile Send private message
MAHMOOD
Smarty n00b


Joined: 23 Jun 2013
Posts: 4

PostPosted: Sun Jun 23, 2013 1:22 pm    Post subject: Reply with quote

<?

echo"ok"
?>

not work Mad
Back to top
View user's profile Send private message
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 541

PostPosted: Sun Jun 23, 2013 5:09 pm    Post subject: Reply with quote

MAHMOOD wrote:
<?

echo"ok"
?>

not work Mad


http://www.smarty.net/docs/en/language.function.eval.tpl

"{eval} is used to evaluate a variable as a template."

It is not used to evaluate PHP.
Back to top
View user's profile Send private message
MAHMOOD
Smarty n00b


Joined: 23 Jun 2013
Posts: 4

PostPosted: Tue Jun 25, 2013 4:30 pm    Post subject: Reply with quote

no work I'm try i have php code in mysql I wan't view in the menu

but Eval not work for smarty
Back to top
View user's profile Send private message
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 541

PostPosted: Tue Jun 25, 2013 5:42 pm    Post subject: Reply with quote

Ok, I don't think we are understanding each other.

Are you saying for this code:

{eval var=$info.textblock }

$info.textblock contains PHP or not?
Back to top
View user's profile Send private message
MAHMOOD
Smarty n00b


Joined: 23 Jun 2013
Posts: 4

PostPosted: Wed Jun 26, 2013 10:18 am    Post subject: Reply with quote

the $info.textblock

for loop the query mysql data

the $info.textblock is have code html and php inside the database

is work fine view the html code only php code not work

code while for php


Code:
   while ($block1 =mysql_fetch_array ($query2))
   {
      $block[] = $block1;
}


loop for smarty

Code:
<td width="16%" valign="top">{foreach name="main" from=$blockl item="info"}
{if not $smarty.foreach.last and $smarty.foreach.cats.iteration is div by 1}
<table class="left" border="0" width="10%" cellspacing="0" cellpadding="0">
   <tr>
      <td id="blockh" width="85">{$info.name_block}</td>
   </tr>
   <tr>
      <td id="blockm" width="85">{$info.textblock}</td>
   </tr>
</table>
{/if}
{/foreach}</td>
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jun 26, 2013 3:47 pm    Post subject: Reply with quote

By default the execution of PHP code in templates is disabled.

See http://www.smarty.net/docs/en/variable.php.handling.tpl

You must set
Code:
$smarty->php_handliing = Smarty::PHP_ALLOW;
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Help Wanted (commercial) All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP