yiiext / twig-renderer

Allows to use Twig template engine in Yii framework views
http://www.yiiframework.com/extension/twig-view-renderer/
70 stars 30 forks source link

call widget extension inside the template #7

Closed bicf closed 12 years ago

bicf commented 12 years ago

I try to use some widget extension inside the twig templates (eg.: http://www.yiiframework.com/extension/faceplugs).

the widget code is:

$this->widget('ext.faceplugs.LikeButton', array( 'url' => 'http://www.exemple.com', 'layout' => 'button_count', 'action' => 'recommend', 'colorscheme' => 'dark', ),true);

I try to translate as:

        {{ this.widget( "ext.faceplugs.LikeButton", {
           'url': 'http://www.exemple.com',
           'layout': 'button_count',
           'action': 'recommend',
           'colorscheme': 'dark'
        } ,true) }}

But I got the following error: An exception has been thrown during the rendering of a template ("Object configuration must be an array containing a "class" element.") in "views/

So I try this one (just to a try):

        {{ this.widget( {'class': 'ext.faceplugs.LikeButton'}, {
           'url': 'http://www.exemple.com',
           'layout': 'button_count',
           'action': 'recommend',
           'colorscheme': 'dark'
        } ,true) }}

But I got:

Illegal offset type in isset or empty .../framework/YiiBase.php(267)

Your example using CMenu works well, so why not an Yii extension?

bicf commented 12 years ago

May be I sloved.

Into the extension there were:

$var = Yii::app()->params->fbAppId

I suppose new version of Yii want the getter, so I've tranform into:

Yii::app()->getParams()->fbAppId

Jut to not forget also the setter:

Yii::app()->params->fbRootSet = true;

became:

Yii::app()->setParams(array('fbRootSet'=>true));

So nothing twig related :)