This extension allows you to use Smarty templates in Yii.
This extension allows you to use Smarty templates in Yii.
how to use Yii::app() in Smarty View?
unused Smarty too long
where can I download the extension and how to use it ? Thanks
jerry2801
Why do you want to use Yii::app?
Fansy Gong
You can check it out from SVN: http://code.google.com/p/yiiext/source/browse/#svn/trunk/app/extensions/CSmartyViewRenderer
You should consider periodically packaging the SVN up into a zip and adding it to the download page to help people out.
so…how to use it, finally?
<?= CHtml::beginForm(); ?>
<?= CHtml::endForm(); ?>
<? $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=> Yii::t('site', 'Login'), 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=> Yii::t('site', 'Logout'), 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
just replacing ‘vars’ is not enough to be smarty renderer
Yes, you need to wrap necessary functionality into Smarty plugins: http://code.google.com/p/yiiext/issues/detail?id=3.
how to use smarty in yii?
I dont get any documentation about how to use smarty in yii…
and I get error when install smarty on yii.
I have following this instruction
* Copy latest version of Smarty (libs contents) to vendors/Smarty/.
*
* Add the following to your config file 'components' section:
*
* 'viewRenderer'=>array(
* 'class'=>'application.extensions.Smarty.CSmartyViewRenderer',
* 'fileExtension' => '.tpl',
* //'pluginsDir' => 'application.smartyPlugins',
* //'configDir' => 'application.smartyConfig',
* ),
but there are still error,
I copy that above into frameworks folder not into myblog’s folder.
and CSmartyViewRenderer.php copied into myblog’s folder which is my application folder
so the directory structure in my yii project is
./
+ myblog
+ framework
+ CHANGELOG
+ LICENSE
+ README
the error is:
Description
require_once(Smarty/Smarty.class.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory
Source File
/mnt/win_d/www/website/latihan/yii/blogformatika/protected/extensions/Smarty/CSmartyViewRenderer.php(35)
please help me…
thanks
As described in readme, Smarty should be copied to /mnt/win_d/www/website/latihan/yii/blogformatika/protected/vendors/Smarty/ (there should be Smarty.class.php).
oh … I guess, vendors directory on framework… because defaultly. when I have run yii console, there are no vendors directory…
oh ya sir… so how to use smarty & yii widget?
can you give me an example sir?
I very newbea in yii… and I can’t understand the yii documentation…
thanks…
As mentioned before, you need to wrap functionality needed into Smarty plugins: http://code.google.com/p/yiiext/issues/detail?id=3
oh yes… thanks you sir, the link that mentioned above post are miss but, this link now is works…
thank you very much…much sir
Hi everybody,
I was reading the artycle about Smarty into Yii, and I try to download de extention, but the download link no longer exists. I try to SVN but there is nothing yet. Some one know how can I download it?
Sorry for my english(I’m Brazilian).
Attached file to extension page.
Hello every one
i have follow the instruction
and replace
\www\testdrive\protected\views\user\create.php
with
\www\testdrive\protected\views\user\create.tpl
all things right i think
what i need now how to assign variable to this .tpl
link $smarty->assign
so ?
You should do it the same way as with native Yii templates:
class MyController extends CController {
function actionIndex(){
$this->render('template', array(
'variable' => 'value'
));
}
}
Hi samdark,
I got this error, could you tell me what should i do?
PHP Error
Description
include(Smarty_Internal_Data.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
Source File
/var/www/yii/framework/YiiBase.php(395)
00383: * @return boolean whether the class has been loaded successfully
00384: */
00385: public static function autoload($className)
00386: {
00387: // use include so that the error PHP file may appear
00388: if(isset(self::$_coreClasses[$className]))
00389: include(YII_PATH.self::$_coreClasses[$className]);
00390: else if(isset(self::$classMap[$className]))
00391: include(self::$classMap[$className]);
00392: else
00393: {
00394: if(strpos($className,'\\')===false)
00395: include($className.'.php');
00396: else // class name with namespace in PHP 5.3
00397: {
00398: $namespace=str_replace('\\','.',ltrim($className,'\\'));
00399: if(($path=self::getPathOfAlias($namespace))!==false)
00400: include($path.'.php');
00401: else
00402: return false;
00403: }
00404: return class_exists($className,false) || interface_exists($className,false);
00405: }
00406: return true;
00407: }
BTW, could you update your readme page and make it more clear please? It is very confused.
Thanks
Changyong
Do you have Smarty files in the correct location? Also try to use code from SVN: http://code.google.com/p/yiiext/source/browse/#svn%2Ftrunk%2Fapp%2Fextensions%2Fyiiext%2Frenderers%2Fsmarty
Same Problem here, I use the latest release of Smarty (3.0.6).
The Problem seems to be that the Yii autoloader ist called before the Smarty autoloader and fails because Smarty Class Files are not in Yii style.