Yii Framework Forum: Smarty view renderer - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Smarty view renderer Allows you to use Smarty templates in Yii Rate Topic: -----

#1 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 11 October 2009 - 10:15 AM

This extension allows you to use Smarty templates in Yii.

http://www.yiiframew...-view-renderer/
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#2 User is offline   jerry2801 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 504
  • Joined: 18-November 09

Posted 31 December 2009 - 01:30 AM

how to use Yii::app() in Smarty View?

unused Smarty too long :blink:
0

#3 User is offline   Fansy Gong 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 30-December 09

Posted 31 December 2009 - 02:05 AM

where can I download the extension and how to use it ? Thanks
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 31 December 2009 - 05:47 AM

jerry2801
Why do you want to use Yii::app?

Fansy Gong
You can check it out from SVN: http://code.google.c...rtyViewRenderer
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#5 User is offline   scythah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 44
  • Joined: 20-April 09

Posted 31 December 2009 - 07:45 AM

You should consider periodically packaging the SVN up into a zip and adding it to the download page to help people out.
0

#6 User is offline   Andrey G. 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 64
  • Joined: 25-August 09
  • Location:Russia

Posted 28 January 2010 - 08:27 AM

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 :)
Just Do It!
0

#7 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 28 January 2010 - 08:59 AM

Yes, you need to wrap necessary functionality into Smarty plugins: http://code.google.c...es/detail?id=3.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#8 User is offline   Dan Din Dun 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 09-February 10

Posted 09 February 2010 - 04:09 PM

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
Thanks and Kind Regards
------
DanDinDun
0

#9 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 10 February 2010 - 04:55 AM

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).
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#10 User is offline   Dan Din Dun 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 09-February 10

Posted 10 February 2010 - 05:37 AM

 samdark, on 10 February 2010 - 04:55 AM, said:

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..
Thanks and Kind Regards
------
DanDinDun
0

#11 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 10 February 2010 - 05:41 AM

As mentioned before, you need to wrap functionality needed into Smarty plugins: http://code.google.c...ues/detail?id=3
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
1

#12 User is offline   Dan Din Dun 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 09-February 10

Posted 10 February 2010 - 05:49 AM

 samdark, on 10 February 2010 - 05:41 AM, said:

As mentioned before, you need to wrap functionality needed into Smarty plugins: http://code.google.c...ues/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 :-)
Thanks and Kind Regards
------
DanDinDun
0

#13 User is offline   ronaldo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 13-July 10

Posted 13 July 2010 - 08:25 AM

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).
0

#14 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 13 July 2010 - 12:43 PM

Attached file to extension page.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#15 User is offline   fat7i 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 25-October 10

Posted 26 October 2010 - 06:32 PM

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
0

#16 User is offline   fat7i 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 25-October 10

Posted 30 October 2010 - 06:18 PM

so ?
0

#17 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 31 October 2010 - 09:00 AM

You should do it the same way as with native Yii templates:
class MyController extends CController {
  function actionIndex(){
    $this->render('template', array(
      'variable' => 'value'
    ));
  }
}

Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#18 User is offline   Changyong 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-December 10

Posted 25 December 2010 - 08:49 AM

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
0

#19 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,374
  • Joined: 17-January 09
  • Location:Russia

Posted 25 December 2010 - 05:26 PM

Do you have Smarty files in the correct location? Also try to use code from SVN: http://code.google.c...derers%2Fsmarty
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#20 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 480
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 04 January 2011 - 04:13 PM

 Changyong, on 25 December 2010 - 08:49 AM, said:

I got this error, could you tell me what should i do?


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.
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users