/** * Formats the value as an link tag using FPM module. * @param mixed $value the value to be formatted * @param array $options * @return string the formatted result */ public function asFile($value, $options = []) { if (!$value) { return $this->nullDisplay; } $file = FPM::transfer()->getData($value); if (in_array($file->extension, ['jpg', 'png', 'gif', 'tif', 'bmp'])) { $linkLabel = FPM::image($file->id, 'admin', 'file'); } else { $linkLabel = FPM::getOriginalFileName($file->id, $file->base_name, $file->extension); } return Html::a($linkLabel, FPM::originalSrc($value), ['target' => '_blank']); }
/** * @param $attribute * @param array $element * @param ActiveRecord $model * @param string|null $language * * @return string */ public function renderUploadedFile($model, $attribute, $element, $language = null) { $content = ''; if ($element['type'] == static::INPUT_FILE && isset($model->{$attribute}) && $model->{$attribute}) { $file = FPM::transfer()->getData($model->{$attribute}); $content .= Html::beginTag('div', ['class' => 'file-name']); $content .= Html::button(\Yii::t('app', 'Delete file'), ['class' => 'delete-file', 'data' => ['modelName' => $model->className(), 'modelId' => $language ? $model->model_id : $model->id, 'attribute' => $attribute, 'language' => $language]]); if (in_array($file->extension, ['jpg', 'png', 'gif', 'tif', 'bmp'])) { $linkLabel = FPM::image($file->id, 'admin', 'file'); } else { $linkLabel = FPM::getOriginalFileName($file->id, $file->base_name, $file->extension); } $content .= Html::a($linkLabel, FPM::originalSrc($model->{$attribute}), ['target' => '_blank']); $content .= Html::endTag('div'); } return $content; }
echo $this->render('@app/themes/basic/layouts/_header', ['breadcrumbsLinks' => $model->getBreadcrumbsLinks()]); ?> <div class="row blog-post-page"> <div class="col-md-9 blog-box"> <!-- Start Single Post Area --> <div class="blog-post gallery-post"> <!-- Post Thumb --> <div class="post-head"> <?php if (isset($titleImage->file_id)) { ?> <?php echo FPM::image($titleImage->file_id, 'article', 'title', ['alt' => $model->label]); ?> <?php } ?> </div> <!-- Start Single Post Content --> <div class="post-content"> <div class="post-type"><i class="icon-pencil-4"></i></div> <h2><?php echo $model->label; ?> </h2> <ul class="post-meta"> <li><?php
<?php foreach ($models as $article) { ?> <li> <?php $titleImage = $article->titleImage; ?> <?php $url = $article->getViewUrl(); ?> <div class="widget-thumb"> <a href="<?php echo $url; ?> "><?php echo FPM::image($titleImage->file_id, 'article', 'thumb', ['alt' => $article->label]); ?> </a> </div> <div class="widget-content"> <h5><a href="<?php echo $url; ?> "><?php echo $article->label; ?> </a></h5> <span><?php echo Yii::$app->formatter->asDate($article->date, 'd MMM yyyy'); ?> </span>