Skip to content

Components, Elements, or Snippets

dantleech edited this page Sep 25, 2014 · 2 revisions

Use cases

  • Hotel
  • Car
  • Footer
  • Sidebar

Naming

First of all, Blocks - Typically a block is a position which can be filled with something in a templating system or CMS. The conventional use of the term Block is not related to our use case.

The following are candidate names and definitions:

Element: One of the simplest or essential parts or principles of which anything consists, or upon which the constitution or fundamental powers of anything are based. [1913 Webster]

Snippet: A small part or piece

Component: A constituent part; an ingredient.

Snippet implies something small or incomplete, while Element implies something more complete, foundational, and not necessarily small.

Snippet is also more commonly used in relation to templates (both "code" and html):

Element on the otherhand might perhaps be better used to talk about the atoms of our system, e.g. the content types and therefore is possibly not the best choice:

I wonder if components would be better, e.g. Component is used by Magnolia CMS for something similar:

Structures, Pages and Components

Currently there is a templates/ directory containing the XML templates for the structures.

I propose we rename templates/ to pages/ and so we have the following file structure:

app/
  Resources/
    pages/
      homepage.xml
      product.xml
      product-overview.xml
      faq.xml
    components/
      hotel.xml
      banner.xml
      sidebar.xml

Class Inheritance and Packaging

We maintain the Structure class, but it becomes the abstract super-type of new Page and Component classes.

The new class should be contained within the Core package it represents a fundamental concept of the Sulu CMF.