當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Authors::getNameAuthor方法代碼示例

本文整理匯總了PHP中app\models\Authors::getNameAuthor方法的典型用法代碼示例。如果您正苦於以下問題:PHP Authors::getNameAuthor方法的具體用法?PHP Authors::getNameAuthor怎麽用?PHP Authors::getNameAuthor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Authors的用法示例。


在下文中一共展示了Authors::getNameAuthor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: function

?>
<div class="books-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
echo $this->render('_search', ['model' => $searchModel]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', 'name', ['attribute' => 'preview', 'content' => function ($model, $key, $index, $column) {
    if (!empty($model->preview)) {
        return Html::a('<img src="img/' . $model->preview . '" style="max-width: 100px; max-height: 100px;">', 'img/' . $model->preview, ['class' => 'view_image']);
    } else {
        return NULL;
    }
}], ['attribute' => 'author_id', 'value' => function ($data) {
    return Authors::getNameAuthor($data->id);
}], 'date', 'date_create', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{edit} {view} {delete}', 'buttons' => ['edit' => function ($url, $data) {
    Url::remember(Url::current());
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Url::toRoute(['/books/update', 'id' => $data->id]), ['target' => '_blank']);
}, 'view' => function ($url, $data) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', Url::toRoute(['/books/view', 'id' => $data->id]), ['class' => 'fancybox.ajax', 'id' => 'view_modal']);
}, 'delete' => function ($url, $data) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', Url::toRoute(['/books/delete', 'id' => $data->id]), ['data-confirm' => Yii::t('app', 'Вы действительно хотите удалить эту книгу?')]);
}]]]]);
?>

</div>
開發者ID:Wulfagor,項目名稱:Testing-Task,代碼行數:31,代碼來源:index.php

示例2:

<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\models\Authors;
/* @var $this yii\web\View */
/* @var $model app\models\Books */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Books', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="books-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'name', 'date_create', 'date_update', ['attribute' => 'preview', 'value' => 'img/' . $model->preview, 'format' => ['image', ['width' => '100']]], 'date', ['attribute' => 'author_id', 'value' => Authors::getNameAuthor($model->id)]]]);
?>

</div>
開發者ID:Wulfagor,項目名稱:Testing-Task,代碼行數:23,代碼來源:view.php


注:本文中的app\models\Authors::getNameAuthor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。