frankmullenger / gallery
此包的最新版本(1.1.x-dev)没有可用的许可证信息。
SilverStripe 图库模块
1.1.x-dev
2014-10-09 22:31 UTC
Requires
- silverstripe/cms: >=3.1.2
- silverstripe/framework: >=3.1.2
This package is not auto-updated.
Last update: 2024-09-14 15:52:43 UTC
README
维护者联系方式
要求
- SilverStripe 框架 >3.1.2
- SilverStripe CMS >3.1.2
版本
1.1
文档
一个非常简单的图库解决方案,用于上传图像并在使用 Fancybox 的基本图库中显示它们。
可以将图库添加到任何页面类型,此模块附带 GalleryPage 作为示例。
使用自定义的 UploadField 来管理图像,允许批量上传图像,然后使用拖放排序和编辑标题。
已提供了一个使用 Fancybox2 的示例实现。您需要为商业网站购买Fancybox 许可证。Fancybox 可以轻松替换为应用图库的每个页面类型。
安装说明
Composer
composer require frankmullenger/gallery 1.0.*@dev
- 访问您的网站.com/dev/build?flush=1 重建数据库(您可能需要两次)。
手动
- 将此目录放置在 SilverStripe 安装根目录中,重命名文件夹为 'gallery'。
- 访问您的网站.com/dev/build?flush=1 重建数据库(您可能需要两次)。
用法
扩展用法
您可以通过将此模块的扩展应用于页面类型,将任何页面类型变为图库。以下以 GalleryPage 为例
创建页面类型
在控制器中包含 JavaScript 来显示图库中的图像和一个表示连接表的 DataObject。由于我们正在应用具有多对多 Images 组件的扩展,您需要一个表示连接的 DataObject {PageType}_Images。此对象需要标题和排序顺序字段。
<?php class GalleryPage extends Page { } class GalleryPage_Controller extends Page_Controller { public function init() { parent::init(); Requirements::javascript('gallery/javascript/jquery-1.7.1.min.js'); Requirements::javascript('gallery/javascript/jquery.fancybox.js'); Requirements::javascript('gallery/javascript/GalleryPage.js'); Requirements::css('gallery/css/jquery.fancybox.css'); } } class GalleryPage_Images extends DataObject { static $db = array ( 'PageID' => 'Int', 'ImageID' => 'Int', 'Caption' => 'Text', 'SortOrder' => 'Int' ); }
在此过程中,您可能需要运行 /dev/build 两次以确保连接对象正确创建。
创建模板
以 GalleryPage.ss 布局模板为例,遍历有序图像,并使用必要的标记来显示您的 lightbox JavaScript。
<% loop OrderedImages %> <a class="fancybox" data-fancybox-group="gallery" href="$Filename" title="$Caption"> $SetSize(250,250) </a> <% end_loop %>
应用扩展
在配置 yaml 文件中应用扩展到页面类型
GalleryPage: extensions: - 'Gallery_PageExtension'
归属
此扩展使用
许可证
Copyright (c) 2013, [Frank Mullenger](http://nz.linkedin.com/in/frankmullenger)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.