我制作了一个小部件,根据从小部件类传递的参数(国家、居住地等)显示用户列表,我渲染视图,一切似乎都很好,但民意调查开始更新用户列表其他参数,也就是调用方法,说-更新重建列表,可以吗?
从 10-08 编辑查看代码:
<?php
use yii\helpers\HTML;
use yii\widgets\Pjax;
use app\models\desire;
$model=new desire();
$a_rows=$model->get_desire_for_search_page($user_id,$status,$category);
?>
<?php Pjax::begin(); ?>
<a id="a_pjax" href="/profile/search-desires?user_id=0&status=0&category=0" style="/*display:none;*/">Обновить</a>
<ul class="init_content">
<?php
foreach ($a_rows as $desire)
{
$fname=$desire["fname"];
if($fname=="")
{
$fname="/css/img/ico_event_family.svg";
}
$name=HTML::encode($desire["name"]);
$komm=mb_substr(strip_tags(HTML::decode($desire["komm"])),0,140)."...";
$dt= get_normal_date($desire["dt_add"]);
$dt_end= get_normal_date($desire["dt_end"]);
$id=$desire["id"];
$url="/profile/desire/show?id=$id";
?>
<li id="desire_list_li_<?php echo $id?>">
<div class="desirebox">
<div class="desirebox_left">
<a href="<?php echo $url ?>"><img src="<?php echo $fname ?>" width="90" height="90" alt=""/></a>
</div>
<div class="desirebox_right">
<a href="<?php echo $url ?>" class="eventbox_th"><?php echo $name ?></a>
<div class="desirebox_target"><?php echo $komm ?></div>
<div class="desirebox_period">Период: с <?php echo $dt ?> по <?php echo $dt_end ?></div>
<div class="event_editbox">
<a href="javascript:void(0);" onclick="check_desire_close(<?php echo $id?>);" title="Отметить сбышемся"><i class="fa fa-check-circle"></i></a>
<a href="javascript:void(0);" onclick="del_desire(<?php echo $id?>,'<?php echo $name ?>')" title="Удвлить"><i class="fa fa-close"></i></a>
<a href="/profile/desire/edit?id=<?php echo $id?>" title="Редактировать"><i class="fa fa-gear"></i></a>
</div>
</div>
</div>
</li>
<?php
}
?>
</ul>
<?php Pjax::end(); ?>
控制器代码:
public function actionSearchDesires($user_id,$status,$category)
{
//проверяем авторизован юзер или нет
if ($_SESSION["user_login"] == 0) {
Yii::$app->session->setFlash('error', "Вы не авторизованы на портале!");
return $this->redirect(['/star/index']);
}
if($status==0)
{
$status="";
}
if($status==1)
{
$status=" and flg_close=0 ";
}
if($status==2)
{
$status=" and flg_close=1 ";
}
$this->view->params['user_edit'] = 1;
\Yii::$app->view->params['desire_proces'] = 1;
\Yii::$app->view->params['desire_edit']=1;
return $this->render('search_desire_widget', [
'user_id' => $user_id,'status'=>$status, 'category'=>$category
]);
}
这就是它的名称:
//передаем во вью массив
$model=new desire();
$a_rows=$model->get_desire_for_search_page(Yii::$app->userrows->get("id"),0,0);
echo $this->render('search_desire_widget', [
'a_rows' => $a_rows,
'user_id'=>Yii::$app->userrows->get("id"),
'status' => 0,
'category' => 0,
]);