devp-eu / tmcms-module-gallery

TMCms 模块画廊

dev-master 2018-09-02 18:36 UTC

This package is not auto-updated.

Last update: 2024-09-15 23:27:22 UTC


README

TMCms 模块画廊

该模块作为独立模块添加图像画廊功能,并且可以自动为任何其他模块中显示的每个实体创建内部画廊,例如产品、文章等。

实体使用

创建画廊列

// Data for table
...
$product = new ProductEntity();
$entity_class = strtolower(Converter::classWithNamespaceToUnqualifiedShort($product));

$images = new ImageEntityRepository();
$images->setWhereItemType($entity_class);
...
// Table Helper
...
'columns' => [
  ...,
  'gallery'    => [
    'type'   => 'gallery',
    'images' => $images,
  ],
  ...,
],
...

并在 CmsClass 中添加管理画廊图片的方法

...
public function images()
{
  $product_id = ... // whatever you need
  $product = new ProductEntity($product_id);
  echo ModuleGallery::getViewForCmsModules(product);
}