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

How can I enable {php} tags in Smarty 3.1 ?

 
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 -> Installation and Setup
View previous topic :: View next topic  
Author Message
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Mon Jun 27, 2011 11:33 pm    Post subject: How can I enable {php} tags in Smarty 3.1 ? Reply with quote

As the title says, i downloaded smarty 3.1, everything works fine, but i can't enable php tags, i read the changelog and somewhere in there says sth about smartyBC, as it has the php allow condition, but how in the gods name can i enable it again ? Updated from 3.0.8
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Jun 28, 2011 1:35 am    Post subject: Reply with quote

It's all outlined in the notes that come with it.

http://smarty-php.googlecode.com/svn/branches/Smarty_3_1_DEV/README_3_1_DEV

// include('Smarty.class.php');
include('SmartyBC.class.php');
Back to top
View user's profile Send private message Visit poster's website
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Tue Jun 28, 2011 11:27 am    Post subject: Reply with quote

i changed to include('inc/libs/SmartyBC.class.php');
Code:
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template ".\inc/files\game.tpl" on line 82 "{php} require('actions/'.$_GET["screen"].'.php'); {/php}" unknown tag "php"' in


It still seems that I have to enable the tags from somewhere. I know that in 3.0.8 i had allow_php_tags = true, but here ? what do i need to change in smarty backwards compiler ?

And yes, i deleted the cache and compiled directory contents..
Back to top
View user's profile Send private message
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Tue Jun 28, 2011 1:00 pm    Post subject: Reply with quote

Oh I got it, you need to set $smarty = new SmartyBC; instead of new Smarty ! Thanks anyway.
Back to top
View user's profile Send private message
hkirsman
Smarty Rookie


Joined: 13 Apr 2011
Posts: 10

PostPosted: Wed Jun 29, 2011 3:51 pm    Post subject: Reply with quote

Or you could modify the old php plugin and add it to externals\smarty\libs\plugins\block.php.php like it use to be.

Code:

<?php
/**
 * Smarty plugin to execute PHP code
 *
 * @package Smarty
 * @subpackage PluginsBlock
 * @author Uwe Tews
 */

/**
 * Smarty {php}{/php} block plugin
 *
 * @param string $content contents of the block
 * @param object $template template object
 * @param boolean $ &$repeat repeat flag
 * @return string content re-formatted
 */
function smarty_block_php($params, $content, $template, &$repeat)
{
    /*if (!$template->allow_php_tag) {
        throw new SmartyException("{php} is deprecated, set allow_php_tag = true to enable");
    } */
    eval($content);
    return '';
}

?>
Back to top
View user's profile Send private message
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Wed Jun 29, 2011 4:07 pm    Post subject: Reply with quote

I think it's quite easier to switch from replace Smarty (case sensitive) in any file with SmartyBC that will change the include and the class initialisation.
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 -> Installation and Setup 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