public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     $this->agent = Helper::agent();
     return true;
     // or false to not run the action
 }
Example #2
0
<?php

$this->params['breadcrumbs'][] = '搜索';
$this->params['breadcrumbs'][] = $keyword;
$agent = \common\components\Helper::agent();
?>
    <div class="row">
        <div class="col-md-9">
            <section>
                <?php 
echo yii\widgets\Breadcrumbs::widget(['options' => ['class' => 'breadcrumb mb0'], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
                <?php 
foreach ($topic as $t) {
    ?>
                    <?php 
    $topicInfo = \common\models\Topic::Info($t['topic_id']);
    ?>
                    <?php 
    $userInfo = \common\models\User::Info($topicInfo['user_id']);
    ?>
                    <?php 
    $lastReplyUser = \common\models\User::Info($topicInfo['last_reply_user']);
    ?>
                <article class="item">
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">
                        <tbody><tr>
                            <?php 
    if ($agent == 'is_iphone' || $agent == 'is_android') {
        ?>
                                <td width="24" valign="middle" align="center"><a href="/member/<?php