Skip to content
Wayne Roddy edited this page Aug 25, 2015 · 3 revisions

MXT framework

Templates

The primary key (PK) for Templates is ID, and they auto-increment. If we don't want to change the [[*template]] value for every Resource in a site when a new theme is installed, we have to assume the Template-Resource relation and Template ID assignment is immutable. Further, for the sake of assigning relevant TVs to Templates (and the Resources that use them, e.g. "Blog Posts"), we must decide on a standard set of TVs related to specific Template IDs, and conform every site to this structure.

If we adopt this model, then as per the section on Chunks below, ANY THEME package would actually contain only Chunks, and static asset files.

Resources

Similarly to Templates, Resources are also PK'd on ID, so a compatible theme will never refer to any Resource by ID. [[*id]], [[+id]], [[*parent]], [[+parent]], [[++site_start]] — these are of course fine.

Significant "parent" or "container" relationships can be made via custom Theme System Settings. Ex. [[++flatso.blog_id]] for the "Blog" Collection ID.

Chunks

Chunks will almost certainly be the mainstay of any true theming system in MODX, because they are called by "name". So we can play with the way we name Chunks to make them "themeable". For example, this is the "BaseTemplate" for interchangeable themes:

[[$mxt.[[*content_tpl]]_start_[[++mxt.theme]]]]
[[$mxt.[[*content_tpl]]_header_[[++mxt.theme]]]]
[[$mxt.[[*content_tpl]]_content_[[++mxt.theme]]]]
[[$mxt.[[*content_tpl]]_footer_[[++mxt.theme]]]]
[[$mxt.[[*content_tpl]]_end_[[++mxt.theme]]]]

In this example, if a site used only this Template, or Templates very similar to this, then changing a System Setting [[++mxt.theme]] will swap out all Chunks being used, and [[*content_tpl]] sets a more specific layout variable. The value for this TV is: Page==page||Listing==listing||Grid==grid||Gallery==gallery. If a theme has no need for a certain Chunk on that list, it cannot omit it — it must simply be empty, and Template must remain untouched.

###Assets

Static Theme Assets will be stored in this folder:

assets/mx-themes/theme-name

The folder hierarchy should be:

  • screenshot.jpg
  • readme.md
  • /css
  • /js
  • /images
Clone this wiki locally