【发布时间】:2019-09-13 02:04:48
【问题描述】:
我确信这很简单,但目前证明它有点超出我的能力。
我制作了一个插件,我想用它来显示运行良好的画廊。但是,尝试添加我在组件中创建的画廊的选项被证明是困难的。
当我将组件添加到页面时,我现在可以选择我创建的所有画廊,但根据我选择的画廊来显示画廊是我没有成功的做法。
任何帮助将不胜感激!
我确信这很简单,但目前证明它有点超出我的能力。
我制作了一个插件,我想用它来显示运行良好的画廊。但是,尝试添加我在组件中创建的画廊的选项被证明是困难的。
当我将组件添加到页面时,我现在可以选择我创建的所有画廊,但根据我选择的画廊来显示画廊是我没有成功的做法。
任何帮助将不胜感激!
组件/Gallery.php:
use Cms\Classes\ComponentBase;
use MartinSmith\Gallerys\Models\Gallery as GalleryModel;
class gallerys extends ComponentBase
{
public $gallery;
public function componentDetails(){
return [
'name' => 'Frontend Gallery',
'description' => 'A gallery for you webpage'
];
}
public function defineProperties() {
$lists = $this->getLists();
return [
'galleryName' => [
'title' => 'Gallery',
'type' => 'dropdown',
'placeholder' => 'Select Gallery',
'options' => $lists
]
];
}
public function getLists() {
$agreements = GalleryModel::all()->pluck('name', 'id');
return $agreements->toArray();
}
public function getList() {
$agreement = GalleryModel::where('id', $this->property('galleryName'))->get();
return $agreement->first();
}
}
组件/图库/default.htm:
{% set gallerys = __SELF__.gallery %}
{% for gallery in gallerys %}
<div class="container-fluid px-0">
<div class="gallery">
<div class="row">
{% for image in gallery.fullImage %}
<div class="col-md-4 px-0 home-galleryImg">
<a href="{{ image.path }}">
<div class="gallery-imgOverlay">
<p>{{ image.title }}</p>
<h5>{{ image.description }}</h5>
</div>
<img class="img-fluid" src="{{ image.thumb(650,auto) }}" alt="{{ thumbnail.description }}">
</a>
</div>
{% endfor %}
</div>
</div>
</div>
{% endfor %}
【问题讨论】:
标签: plugins components octobercms