|
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 |
dev.himanshu Smarty n00b
Joined: 23 Nov 2011 Posts: 1
|
Posted: Thu Nov 24, 2011 4:32 am Post subject: How Use {Php} tag in smarty 3.1 |
|
|
I want to use {php} tag in smarty templete.
i try this
The constants
SMARTY_PHP_PASSTHRU
SMARTY_PHP_QUOTE
SMARTY_PHP_REMOVE
SMARTY_PHP_ALLOW
have been replaced with class constants
Smarty::PHP_PASSTHRU
Smarty::PHP_QUOTE
Smarty::PHP_REMOVE
Smarty::PHP_ALLOW
but that not work...
help me for that. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Nov 25, 2011 12:09 am Post subject: |
|
|
you must use SmartyBC.class.php for the php tag. |
|
Back to top |
|
Billie67 Smarty n00b
Joined: 20 Oct 2011 Posts: 2
|
Posted: Sat Dec 03, 2011 8:30 am Post subject: |
|
|
Here is my directory structure:
./smartytest.php
./smarty31/* (libs, etc.)
./plugins/block.sayhi.php
The PHP code that initializes smarty is:
require_once('smarty31/libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = getcwd() . '/templates';
$smarty->compile_dir = getcwd() . '/templates_c';
$smarty->plugins_dir[] = getcwd() . '/plugins';
The PHP code for the plugin is:
<?php
function smarty_block_sayhi($params, $content, $smarty, $open) {
if (!$open) {
return 'Hello: ' . $content;
}
}
?>
The error message I get is this:
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/mypath/phptests/templates/page.tpl" on line 11 "{sayhi}" unknown tag "sayhi"'
When the plugin was under the smarty31/libs/plugins directory, it loaded fine. Does this sample code not initialize Smarty correctly? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Dec 03, 2011 10:01 am Post subject: |
|
|
starting with Smarty 3.1 you must use setter functions to set dir directories
Code: |
$smarty-setTemplateDir = ( './templates';
$smarty->setCompileDir = ('./templates_c');
$smarty->addPluginsDir = ('./plugins');
|
|
|
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
|