2017 © Pedro Peláez
 

silverstripe-module silverstripe-svdrequirements

A convenience module enforcing best practices for using Requirements

image

svandragt/silverstripe-svdrequirements

A convenience module enforcing best practices for using Requirements

  • Thursday, April 14, 2016
  • by svandragt
  • Repository
  • 1 Watchers
  • 4 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SvdRequirements

This is a convenience module enforcing best practices for using Requirements., (*1)

Features:

  • Combine a mixed list of JS / CSS assets using a single method.
  • Access to the $this->theme_dir variable in your page controllers.

SvdRequirements will seperate the js from the css files, and combine them for each controller., (*2)

Usage:

  1. Install using composer: composer require "svandragt/silverstripe-svdrequirements:*"

Example: you might have a Page and HomePage extends Page class, each with dozen JS and CSS requirements. Add SvdRequirements::combine($assets); to each init method., (*3)

Done!, (*4)

In our example the site will now have the following files:, (*5)

page_controller.css
homepage_controller.css
page_controller.js
homepage_controller.js

Quick access to theme folder

This optional SvdRequirementsExtension (enabled by default) adds a shortcut to the theme folder by setting a $theme_dir property to the Page_controller which you can access through $this->theme_dir - which would return 'themes/simple' for example., (*6)

You can convert the simple theme to use requirements in 2 steps:, (*7)

  1. Remove all calls to CSS and JS from the templates.
  2. to the Page's init() method add the following code:
$assets = array(
    "{$this->theme_dir}/css/reset.css",
    "{$this->theme_dir}/css/layout.css",
    "{$this->theme_dir}/css/typography.css",
    "{$this->theme_dir}/css/form.css",
    "{$this->theme_dir}/javscript/script.js",
);
SvdRequirements::combine($assets);

I keep a list of known bugs., (*8)

The Versions

14/04 2016

dev-master

9999999-dev

A convenience module enforcing best practices for using Requirements

  Sources   Download

BSD-3-Clause

The Requires

 

caching silverstripe performance requirements