定制 restruct/silverstripe-blockbase 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

restruct/silverstripe-blockbase

最新稳定版本:1.0.8

Composer 安装命令:

composer require restruct/silverstripe-blockbase

包简介

Various tweaks & enhancements on top of Elemental

关键字:

README 文档

README

This module serves as a base on top of Elemental, for blocks based projects by Restruct.

Unset nested blocks .container padding (for first level nested)

In case your project already wraps blocks inside a .container, the block's .container will have double padding. Below CSS unsets this (based on a project which wraps all content in a subnav and a content .col, adapt to your specific project):

.blocks-container {
  // unset padding/margin of (second level ) .container if contained within .subnav-slot-* (before/after)
  &.subnav-slot-before,
  &.subnav-slot-after {
    & > .block-item-wrapper > .container > .row > [class*="col"] > .block-item-wrapper > .container {
      padding: 0;
      // .row & .col* should remain unchanged as there may be multiple columns with a block
    }
  }
}

Functionality:

  • Various Block (Elemental) tweaks (+ block icon/thumbnail preview route at admin/blocktypeicons)
  • ...

Show Block design/thumbnails instead of icons in admin UI (Elemental)

  1. copy & adapt below section to specific project code css to show designed block previews instead of icons
  2. set private static $icon to 'block-design block-section {block-name-offset}'
  3. add stacked blocks img to app/client (.block-name-offset sets offset if multiple stacked in one image)
i.block-section, button.block-section:before {
  background-image: url(~app/client/imgs/block-group-designs_stacked.png);
  background-position: 0 0;
}
i.block-section, button.block-section {
  &.block-name-offset {&, &:before {
    background-position: 0 -128px;
  }}
  &.block-othername-offset {&, &:before {
    background-position: 0 -28px;
  }}
}

Notes

Template relations

The DNADesign/Elemental/Models/ElementalArea.ss template loops over each of the element controller instances. Each controller instance will render $ElementHolder which represents the element contained within a holder div. The wrapper div is the ElementHolder.ss template.

Style layout variants

A list of style layout variants can be set via YAML or private static $styles, the first one being the default.

Restruct\Silverstripe\BlockBase\Blocks\BlockContent:
  styles:
    single-col-wide: 'Single wide column layout'
    single-col-narrow: 'Single narrow column layout'
    double-col-equal: 'Two equal-width columns layout'

The selected $StyleVariant will be available in themplates and is included as class on the wrapper element (DNADesign/Elemental/Layout/BlockHolder.ss). It can also be used to switch between different templates, eg BlockType.ss / BlockType_single-col-wide.ss / etc.

Styl(ing) options (ExtraClass)

Further styling variations can be controlled by activating one or multiple additional CSS classes to the block holder. Options (eg based on theme) can be set via YAML on a project basis, or directly on the block classes (private static $style_options).

Restruct\Silverstripe\BlockBase\Blocks\BlockContent:
  style_options:
    - 'light'
    - 'dark'

Advanced config

Advanced config pointers: https://github.com/silverstripe/silverstripe-elemental/blob/4/docs/en/advanced_setup.md

Allow/disallow specific block types on subsites

(Handled by Restruct\Silverstripe\BlockBase\Extensions\SubsitesPageExtension)

Page:

#  # Example: disallow any blocks on subsites
#  subsites_allowed_elements: false

#  # Example: allow specific elements on subsites
#  subsites_allowed_elements:
#    - Restruct\Silverstripe\BlockBase\Blocks\BlockContent

#  # Example: DISallow specific elements on subsites
#  subsites_disallowed_elements:
#    - Restruct\Silverstripe\BlockBase\Blocks\BlockContent

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-30