Answer the question
In order to leave comments, you need to log in
What is the correct way to call a widget with the following data in yupe?
Greetings, I am just starting to get acquainted with yii, but I suspect that the question is not very smart, please be understanding)
On the article archive page in a certain category, the widget is called by the following code
$this->widget('application.modules.user.widgets.UsersList', array(
'condition' => $condition, 'type' => $type));
<?php
class UsersList extends yupe\widgets\YWidget
{
public $view = 'main';
public $condition = array();
public $type = "professional";
public function run()
{
$id = $this->getId();
if ($this->type == "professional") {
$users = User::model()->professionals();
}
elseif ($this->type == "company") {
$users = User::model()->companies();
}
elseif ($this->type == "contest") {
$users = User::model()->contests();
}
else {
$users = User::model()->organizations();
}
$models = $users->with('categories', 'tags')->findAll($this->condition);
$this->render($this->view, array('models' => $models, 'type' => $this->type, 'id' => $id));
}
}
Array
(
[together] => 1
[condition] => categories.id = :cid
[params] => Array
(
[:cid] => 159
)
[group] => t.id
[limit] => 20
[order] => t.id DESC
)
$this->widget('application.modules.user.widgets.UsersList', array(
'condition' => array(
'limit' => 12,
'together' => true,
'group' => 't.id'
),
'type' =>'contest',
'cid' => 159
));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question