Coder Social home page Coder Social logo

helpfulrobot / touchcast-modulator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from touchcast/modulator

0.0 2.0 0.0 31 KB

A SilverStripe module for dynamically creating pages from smaller components

License: MIT License

ApacheConf 0.48% PHP 86.35% CSS 5.51% JavaScript 6.45% Scheme 1.21%

touchcast-modulator's Introduction

SilverStripe Modulator

Travis Packagist Packagist

Modulator is an extendable system for creating sub-page components. It achieves this by attaching DataObjects to the page in place of the traditional Content body.

Features

  • Draft and publish control on a per-module level
  • Drag-and-drop re-ordering of modules
  • An extendable system for creating your own modules
  • CMS previewing

Installation

Modulator can be installed via Composer;

composer require touchcast/modulator dev-master

After installing, run a /dev/build to generate the database tables.

Usage

Create a ModularPage page within your Site Tree. Add new modules to the page and populate them as required.

Creating modules

Each module consists of a PHP class and a template file.

Start by extending PageModule

class HeroModule extends PageModule {

  // Give the module a name for use within the CMS
  public static $title = "Hero module";

  // Give it a description
  public static $description = "A large title section at the top of the page";

  // Give it a 64x64px icon image
  public static $icon = "mysite/images/module-hero.png";

  // Add any fields required for the module
  private static $db = array(
    "Heading" => "Varchar(128)"
  );

  // Provide custom summary content for the gridfield
  public function getSummaryContent() {
      return $this->Heading;
  }

  // Provide text content from the module to be included in the pages's search index
  public function getSearchBody() {
      return $this->Heading;
  }
}

Next create a template file. It should have the same name as your module class.

<header>
  <h1>$Heading</h1>
</header>

If you want to extend the ModularPage template, you can render the modules by hand using the $ActiveModules loop.

<% loop $ActiveModules %>
<section class="$ClassName.Lowercase <% if $Odd %>odd<% else %>even<% end_if %> order-$Order $ExtraClasses">
  $Content
</section>
<% end_loop %>

Testing

Run phpunit from within the module folder, or /dev/tests from the browser.

touchcast-modulator's People

Contributors

andrewjoll avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.