Coder Social home page Coder Social logo

helpfulrobot / webtorque7-inpage-modules Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webtorque7/inpage-modules

0.0 2.0 0.0 409 KB

Modular content for SilverStripe CMS

License: MIT License

PHP 74.74% CSS 3.04% JavaScript 16.20% Scheme 6.02%

webtorque7-inpage-modules's Introduction

In Page Content Modules

Alternative method to define content in the CMS, either replacing or amending SilverStripe's core "page type" system. Allows authors to insert "content modules" into a page as separate items, which enables more flexible content structures both for sidebar-style content and flexible main content areas.

Features

  • Define your own content modules by subclassing ContentModule
  • Sort modules via drag'n'drop
  • Save module drafts and publish independently of the parent page
  • List all used modules in a separate admin interface, and view their history
  • Reuse content modules on multiple pages by saving them to a library
  • Built-in modules: Text, Image (incl. cropping), related pages

Screenshots

Overview

Admin

Installation

Install the module into a inpage-modules\ folder inside the webroot.

With composer - composer require webtorque7/inpage-modules

Then add the ContentModule_PageExtension class to either your base Page class or select subclasses.

# File: mysite/_config/config.yml
Page:
  extensions:
    - ContentModule_PageExtension

In your template (e.g. themes/<yourtheme>/templates/Layout/Page.ss) you can loop through modules, and have them render with their own templates:

<% loop $SortedContentModules %>
	$forTemplate
<% end_loop %>

Templates

Create a template with same name as the module e.g. ImageModule.ss. Uses the same template inheritance model as SiteTree objects to get the template. By convention it is a good idea to add module templates to themes/<yourtheme>/templates/modules

Multiple Sections

Multiple sections for modules can be added to a page creating a new base class e.g. SideBarModule and setting up a many_many relationship

$many_many = array(
    'SideBarModules' => 'SideBarModule'
);

$many_many_extraFields = array(
    'SideBarModules' => array(
        'Sort' => 'Int'
    )
);

Make sure to add the Sort field. To simplify getting the sorted modules you can overwrite the many many function

public function SideBarModules() {
    return $this->getManyManyComponents('SideBarModules')->sort('Sort');
}

webtorque7-inpage-modules's People

Contributors

kouky4 avatar chillu avatar webtorque7 avatar

Watchers

James Cloos avatar helpfulrobot 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.