pstaender / silverstripe-photogallerypage
添加一个页面类型,用于管理多张图片,包括描述和其他各种选项
v1.2.1
2024-07-29 10:16 UTC
Requires
This package is auto-updated.
Last update: 2024-08-29 10:33:40 UTC
README
添加一个页面类型,用于管理多张图片,包括描述和其他各种选项
将添加以下SiteTree页面类型
GalleryPage
/GalleryPageController
GalleryPageHolder
GalleryPicture
需求
- SilverStripe 4+ (使用v0.6.1适用于SilverStripe 3.x)
安装
$ composer require pstaender/silverstripe-photogallerypage
安装后不要忘记运行dev/build?flush=all
。
方法和行为
所有图片将通过SortedPictures
可用,其中+
表示升序(默认),-
表示降序。所有图片也可以作为URL访问。假设你的GalleryPage的URL为http://localhost/photos
,并且(任意)图片的URLSegment为example-picture
,它将作为http://localhost/photos/example-picture
可用。此行为可以通过配置中的picturesAccessibleViaURL
开关开启/关闭。
在模板中的使用
例如,你的Layout/GalleryPage.ss
可以是
<article class="gallery"> <h1>$Title</h1> <% with CurrentPicture %> <h2>Selected Picture</h2> $Image.ScaleHeight(200) <br /> <span class="previousPicture"> <% with Previous %> <a href="$Link">« $Image.ScaleHeight(100)</a> <% end_with %> </span> <span class="nextPicture"> <% with Next %> <a href="$Link">$Image.ScaleHeight(100) » </a> <% end_with %> </span> <% end_with %> <br /> <h3>All Pictures</h3> <% loop SortedPictures %> <a href="$Link" class="$LinkingMode"> $ImagePreview <% if LinkingMode == 'current' %>selected<% end_if %> </a> <% end_loop %> </article>
配置
在_config/photogallerypage.yml
中查看可用的配置属性,以便您可以覆盖它们。
版权和许可
此项目受GNU通用公共许可证v2许可
图标由Freepik提供 (http://www.flaticon.com/packs/web-design-2)