taitava/silverstripe-slickcarousel

为 Slick carousel 提供的 SilverStripe 封装:"你永远需要的最后一个轮播"。

安装: 103

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 3

分支: 1

开放问题: 2

类型:silverstripe-vendormodule

2.0.1 2019-09-30 11:05 UTC

This package is auto-updated.

Last update: 2024-09-12 09:29:41 UTC


README

SilverStripe 的 Slick carousel 封装。请参阅:http://kenwheeler.github.io/slick/

需求

  • SilverStripe 4(使用本模块的发布线 2.0 及以上版本)
  • 或者:SilverStripe 3(使用本模块的发布线 1.x)
  • unclecheese/display-logic 模块(与 SS4/SS3 兼容的任何版本)

使用方法

README 即将到来!如果需要它,请提出关于 README 的问题,我会尽快处理。但请不要担心,模块使用起来相当简单。最简单的设置只需几个步骤

  1. 通过 Taitava\SlickCarousel\CarouselExtension 扩展你的 Page 类(或 SiteTree 类或任何从 SiteTree 派生的类)。创建一个新的文件 app/_config/slickcarousel.yml 并将以下内容放入其中
Page:
  extensions:
    - Taitava\SlickCarousel\CarouselExtension
  1. 将 $Carousel 放入你的 Page.ss(或类似)布局模板中。
  2. 运行 /dev/build?flush=all
  3. 转到 CMS 并编辑一些页面,寻找新的 Carousel 选项卡。

可以通过 YAML 配置 Slick carousel 选项

Taitava\SlickCarousel\Carousel:
  slick_options:
    autoplay: true

自动播放选项只是一个示例。有关可用选项的完整列表,请参阅:http://kenwheeler.github.io/slick/#settings

该模块仍在开发中,因此 我还没有认为它是稳定的。(更新 2017-01-14:我正在一些网站上使用此模块进行生产,该模块到目前为止表现良好,但如果您遇到任何问题,请告诉我)。然而,Slick 是稳定的,所以实际上没有什么可以破坏的,因为封装相当简单! :)

可选设置

您可以在 app/_config/slickcarousel.yml 中调整这些设置。以下是带有默认值的选项列表。

Taitava\SlickCarousel\Carousel:
  cms_slides_per_page: 50        #How many slides to list in a single page in the Carousel tab in the CMS.
  
  image_placement: background    #Where to place the slide's image inside the carousel slide <div> element:
	                         # - 'background': the image will be used as the <div>'s background-image.
	                         # - 'before-content': the image will be used as an <img> element before the HTML contained in the Content field.
	                         # - 'after-content': the image will be used as an <img> element after the HTML contained in the Content field.
	
  use_image_dimensions: false    # Whether or not to set the slide <div> element's width and/or height to be the same as the image's width and/or
	                         # height. Can be useful when $image_placement is 'background' and you are not using constant dimensions that you
	                         # define in your CSS. Possible values:
	                         # - false
	                         # - 'width-only'
	                         # - 'height-only'
	                         # - true (both width and height)
	                         
  slick_options:                 # Options to pass to the Slick jQuery plugin during initialization. With these you can greatly affect the behaviour
    (an empty array by default   # of the carousel in the frontend.
    so all Slick's default       # This array can contain any option that is mentioned here: http://kenwheeler.github.io/slick/#settings
    values apply by default)     # The options are passed as-is, so if new versions of Slick define new options, no PHP code modifications are needed.
	                         # You just need to manually upgrade the included Slick JavaScript library.
	
CarouselSlide:
  default_sort: Sort             #The default sort order is the order how the slides are drag&dropped in the CMS.
                                 #If you want to randomize the order, set this to 'RAND()'.