[php] link generation
Viewer
- //my view file code
- DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'name',
- 'project_date:date',
- 'client_name',
- 'project_url:url',
- 'detail:html',
- [
- 'attribute' => 'category_id',
- 'value' => $model->category_id ? $model->category->category_name : "Category not selected" //we have getCategory() in Projects class, which returns a magic property 'category', through which we can access Category class attributes.
- ],
- [
- 'label' => 'Project Images',
- 'format' => ['raw'],
- 'value' => $this->render('_test', ['listData' => $model])
- ]
- ],
- ])
- // my _test.php file code
- $link = Yii::getAlias('@frontend/web/projects_pictures/'.$listData->id);
- $path = \yii\helpers\FileHelper::findFiles($link);
- foreach ($path as $pic){
- echo "<img src='$pic' alt='test' />";
- }
Editor
You can edit this paste and save as new:
File Description
- link generation
- Paste Code
- 23 Jan-2022
- 1.01 Kb
You can Share it: