T
T
Tendor2014-08-13 02:18:11
Yii
Tendor, 2014-08-13 02:18:11

How to pass parameters to a Yii widget?

View

<?php $this->widget('ext.widgets.Share', array('params'=>array('url'=>123))); ?>

Widget method
<?php
class Share extends CWidget
{
  public $params = array(
                      'url'=>'value 1',
          );
  
  public function run()
        {
    $this->render('share', $this->params);
  }
  
  }

view share code
<div class="share_social_popup">
    <p>Поделиться:</p>
         <div>
        <a href="#" onclick="Share.vkontakte('<?php echo $url; ?>','TITLE','IMG_PATH','DESC')" class="icons icon_vk_2">В контакте</a>
        <a href="#" class="icons icon_fb_2">facebook</a>
        <a href="#" class="icons icon_tw_2">twitter</a>
        <a href="#" class="icons icon_od_2">Однокласники</a>
        </div>
    <p><a href="#">Скопировать ссылку на это послание</a></p>
  </div>

The result displays: value 1.
Where is the error, where to look?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tendor, 2014-08-15
@Tendor

Issue resolved. Not attentive (

_
_ _, 2014-08-13
@AMar4enko

To the debugger and Yii source code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question