pstaender/silverstripe-photogallerypage

添加一个页面类型,用于管理多张图片,包括描述和其他各种选项

安装: 313

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 3

分支: 1

开放问题: 0

类型:silverstripe-vendormodule

v1.2.1 2024-07-29 10:16 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)