MV
Size: a a a
MV
SS
MV
<?php namespace MyGroup\Blog\Components;
use RainLab\Blog\Components\Posts as RainLabBlogComponentsPosts;
class Posts extends RainLabBlogComponentsPosts
{
}
SS
SS
SS
MV
MV
SS
SS
MV
{% set posts = __SELF__.posts %}
<div class="row preview-blocks">
{% for post in posts %}
<div class="col-md-3 col-sm-4">
<a href="{{ post.url }}" class="preview-block">
<div class="preview" style="background-image: url(
{% if post.image.path != '' %}
{{ post.image.path }}
{% else %}
{{'assets/images/temp/2.png'|theme}}
{% endif %}
)"></div>
<div class="title">
{{ post.title }}
</div>
<div class="date">
{{ post.published_at|date('d.m.Y') }}
</div>
</a>
SS
MV
post.image
== nullSS
SS
MV
public function boot()
{
// add field in admin part
Post::extend(function ($model) {
$model->attachOne['image'] = ['System\Models\File'];
});
Posts::extendFormFields(function ($form, $model, $context) {
if (!$model instanceof Posts) return;
if (!$model->exists) return;
$form->addSecondaryTabFields([
'image' => [
'tab' => 'rainlab.blog::lang.post.tab_manage',
'label' => 'mygroup.blog::lang.post.preview',
'type' => 'fileupload',
'mode' => 'image',
'imageWidth' => 260,
'imageHeight' => 180
]
]);
});
}
SS
SS
MV
SS