如何使用yii2通过图像链接渲染另一个控制器方法?

时间:2018-06-06 19:42:54

标签: yii2

以下代码将呈现图像:

<?= Html::img('@web/img/accept_all_you_see-wallpaper-1680x1050.jpg', ['alt' => 'PicNotFound', 'class' => 'scale-with-grid wp-post-image', 'style' => 'width:960;height:700']); ?>

以下代码会将图像呈现为链接

<?= Html::a('', Yii::getAlias('@web') . '/img/pic1.jpg', ['target' => '_blank', 'alt' => 'PicNotFound', 'class' => 'icon-search']) ?>

如果要通过单击图像渲染另一个Conroller方法,如何编码? 以下代码将通过bootstrap图标实现我的意图,而不是图像!

<div class="col-md-12">
    <?= Html::a('<span class="glyphicon glyphicon-paperclip"></span>', ['/dateianhang/dateianhang/index'], ['title' => 'Anlagen anzeigen', 'data' => ['pjax' => '0']]); ?>
</div>

1 个答案:

答案 0 :(得分:2)

<?= Html::a(
    Html::img(
        '@web/img/accept_all_you_see-wallpaper-1680x1050.jpg',
        ['alt' => 'PicNotFound', 'class' => 'scale-with-grid wp-post-image', 'style' => 'width:960;height:700']
    ),
    ['/dateianhang/dateianhang/index'],
    ['title' => 'Anlagen anzeigen', 'data' => ['pjax' => '0']]
) ?>