Download the PHP package cita/silverstripe-modular without Composer
On this page you can find all versions of the php package cita/silverstripe-modular. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cita/silverstripe-modular
More information about cita/silverstripe-modular
Files in cita/silverstripe-modular
Package silverstripe-modular
Short Description CitaNZ's modular for SilverStripe 4
License MIT
Homepage https://github.com/CITANZ/silverstripe-modular
Informations about the package silverstripe-modular
CitaNZ's SilverStripe modular module
Requires: SilverStripe 4.0+
CitaNZ Modular is a lightweight block module which uses ManymanyList
to link the pages and the content blocks, and builds the site with the "modulated" concept.
It not only allows the users to reuse the same blocks on different pages across site, but also give the developer a safe fall protection when a block class becomes unavailable (e.g. a deleted block subclass will fall back to Block::cass
, instead of crashing the block edit list in the CMS).
Installation
Make sure you also /dev/build?flush=all
on the web too
Enable Modular on the class
Please note: if the page's Content
field is already in use, then DO NOT enable this module!!!
Add $modulated
static variable to the class
and then flush the site cache (/?flush=all
)
Build your on Modular blocks
Create a new class, and extend it from Cita\Modular\Model\Block
Allowing/Disallowing block types
below line will only allow BlockA::class
, BlockB::class
and BlockC::class
on the page
below line will exclude BlockA::class
, BlockB::class
and BlockC::class
from the available block types;
Frontend
To print the modular list, just place $Modulars
in the .ss
files where it's needed
Templating
When a new block subclass is created, the default Block class template (Cita\Modular\Model\Block
) will be applied to keep the frontend page stick together. The next step is to create the new subclass's template (make sure it matches the correct namespace), and then flush the cache on the browser -- now all you need to do is to build your block's HTML in the template file and style it with your frontend skills.
Overriding CitaNZ's modular default templates
If you need to tweak the default block's HTML and/or change how the modular blocks get listed on the page, please follow the steps:
- cp -rf
vendor/cita/silverstripe-modular/templates/Cita
your_theme/templates/.
(replaceyour_theme
accordingly...) - flush (on the browser)
- inspect the
.ss
files in it - do your thing
Caching
To enable cache for a particular block type, add below to the block type's class
and define the getCacheInvalidator
function, and build the conditions for when the cache should be invalidated.
Below is the default invalidator:
It's looking at the block type, block id, and the last edited datetime.
Flex Block
Flex block offers you a quick way to group different blocks in a flex row
. If you are using Vuetify
or Bootstrap
or something similar in your frontend stacks, then all you need to do is to set the column sizes in the CMS. Otherwise, you will have to implement the flexbox
by yourself.
Questions?
Q: Why don't you...
A: Pull request plz
Q: I need to do such such such... so can you add this feature blah blah blah...
A: This module is meant to be lightweight, so let's keep it that way. I offer the nose pick, but I don't do the pick! (bet you don't want that either!)