markocupic / gallery-creator-bundle
Contao CMS 的相册扩展
Requires
- php: ^8.1
- contao/core-bundle: ^5.0
- jaybizzle/crawler-detect: ^1.2
- league/commonmark: ^2.3
Requires (Dev)
- 3.x-dev
- 3.0.1
- 3.0.0
- 2.x-dev
- 2.0.0-RC8
- 2.0.0-RC7
- 2.0.0-RC6
- 2.0.0-RC5
- 2.0.0-RC4
- 2.0.0-RC3
- 2.0.0-RC2
- 2.0.0-RC1
- 2.0.0-Alpha1
- 1.x-dev
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-09-18 11:38:52 UTC
README
Gallery Creator Bundle
Contao CMS 的前端和后端扩展 Contao CMS
此扩展可用于在您的 Contao 安装中创建、显示和管理照片专辑。Gallery Creator Bundle 提供了专辑列表和专辑详情视图。自 2.0.0 版本起,可以使用 markdown 创建专辑描述。
Gallery.Creator.mp4
安装
请使用 Contao 管理器或在您的 CLI 中运行 composer require markocupic/gallery-creator-bundle
来安装此扩展。
CHMOD
转到 Contao 后端设置 并选择默认的 专辑所有者、默认专辑所有者组 并设置默认的 访问权限
重要:如果您保留“专辑所有者”字段为空,则在创建新专辑时,当前登录的后端用户将自动成为专辑所有者。
灯箱
我们强烈推荐使用 Glightbox 作为灯箱。只需在您的 CLI 中运行 composer require inspiredminds/contao-glightbox
命令。请确保您已激活主题的布局设置中的灯箱模板。
CSS
Gallery Creator 将向 body 标签添加 .gc-listing-view
和/或 .gc-detail-view
。这有助于您在列表和详情视图模式中显示或隐藏不想显示的项目。
/** SASS
* Do not display ce elements headline in detail mode
*
*/
body.gc-detail-view {
.ce_gallery_creator {
h2:not([class^="gc-album-detail-name"]) {
display: none;
}
}
}
配置
此相册扩展附带默认配置。如果您想覆盖这些设置,可以在位于 config/config.yml
的公共配置文件中完成此操作。
# config/config.yml # Gallery Creator (default settings) markocupic_gallery_creator: upload_path: 'files/gallery_creator_albums' copy_images_on_import: true read_exif_meta_data: false valid_extensions: ['jpg', 'jpeg', 'gif', 'png', 'webp', 'svg', 'svgz'] # Contao configuration contao: url_suffix: '' #....
"galleryCreatorGenerateFrontendTemplate" - 钩子
使用 "galleryCreatorGenerateFrontendTemplate" 钩子来自适应前端输出。
"galleryCreatorGenerateFrontendTemplate" 钩子在解析相册创建器前端模板之前触发。它传递内容元素对象、模板对象和活动专辑的专辑对象(如果有的话)。"galleryCreatorGenerateFrontendTemplate" 钩子不需要返回值。
<?php // src/EventListener/GalleryCreatorFrontendTemplateListener.php declare(strict_types=1); namespace App\EventListener; use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; use Contao\CoreBundle\DependencyInjection\Attribute\AsHook; use Contao\CoreBundle\Twig\FragmentTemplate; use Markocupic\GalleryCreatorBundle\Model\GalleryCreatorAlbumsModel; #[AsHook(GalleryCreatorFrontendTemplateListener::HOOK, priority: 100)] class GalleryCreatorFrontendTemplateListener { public const HOOK = 'galleryCreatorGenerateFrontendTemplate'; public function __invoke(AbstractContentElementController $contentElement, Fragmenttemplate $template, GalleryCreatorAlbumsModel|null $activeAlbum = null) { $template->set('foo', 'bar'); } }
"galleryCreatorImagePostInsert" - 钩子
使用 "galleryCreatorImagePostInsert" 钩子来适应在向专辑上传新图像时的图片实体。
"galleryCreatorImagePostInsert" 在图像上传并写入数据库后立即执行。它传递图片模型并不需要返回值。
<?php // src/EventListener/GalleryCreatorImagePostInsertListener.php declare(strict_types=1); namespace App\EventListener; use Contao\BackendUser; use Contao\CoreBundle\DependencyInjection\Attribute\AsHook; use Markocupic\GalleryCreatorBundle\Model\GalleryCreatorPicturesModel; use Symfony\Bundle\SecurityBundle\Security; #[AsHook(GalleryCreatorImagePostInsertListener::HOOK, priority: 100)] class GalleryCreatorImagePostInsertListener { public const HOOK = 'galleryCreatorImagePostInsert'; private Security $security; public function __construct(Security $security) { $this->security = $security; } public function __invoke(GalleryCreatorPicturesModel $picturesModel): void { $user = $this->security->getUser(); // Automatically add a caption to the uploaded image if ($user instanceof BackendUser && $user->name) { $picturesModel->caption = 'Holidays '.date('Y').', Photo: '.$user->name; $picturesModel->save(); } } }
祝您玩得开心!