Skip to content
brendo edited this page Aug 10, 2011 · 5 revisions

What is this extension?

Scaffolds allows developers to create Symphony sections from flat files by importing them into the backend interface. Developers can export section definitions and save them for use in other projects. The initial format supported will be JSON others such as XML or YAML may be considered if there is demand.

How does it work?

When a developer creates a new Section, they will have the ability to 'Import' a section definition. This definition will be parsed and will set Section meta data (name, navigation group etc.), and trigger Symphony's interface to rapid build the Section from the definition. The developer will ultimately still have control over the Section as the Import is purely UI/autocomplete, it won't trigger the 'Save' of a section.

Some additional points:

  • If the Section Editor has existing content, the Section definition will not override it.
  • If the definition references Extensions that don't install in the current installation, it will ignore them
  • It would be possible to 'build' a Section from multiple definitions, essentially meaning you could group and export definitions of commonly used fields and rapidly build one Section.

When a Section has been saved, an 'Export' option also appears, allowing a developer to take the current Section and export a definition for reuse later. This will probably be in JSON. Initially this could be done just as you'd expect, outputting a file, but a nice addon might be to look at using localStorage to additionally save definitions too.

Interface

Simple is best, a Export/Import button will do the job for now. Should localStorage be viable, I really like the idea/concept of the Documentator plugin and think something similar could be used having a drawer slide in from a side which would show your 'previously used definitions'. Of course, this is where you could go to town, having a Name and Description, being able to tag them and then filter on them, but that's really pie in the sky sort of stuff, and probably not overly useful just yet.

Writing your own Definition

Writing your own definition is relatively easy. Any form element that is on the Section Editor can be used, with the name of the element's setting, (eg. fields[2][static_options] is static_options) acting as the key, and the value being well, the value.

<input>

"Name": {
    "type": "input",
    "location": "sidebar"
}

<input type='checkbox'>

To set the checkbox to be checked, use yes, for unchecked, use no (or omit the rule)

"Publish": {
    "type": "checkbox",
    "default_state": "yes",
    "description": "Publish this entry?"
}

<select>

Select fields can have their values set as a string (single select), or as an array of objects (multiple select). The object must always have one property, value, with optgroup being optional.

"Tags": {
    "type": "taglist",
    "pre_populate_source": [
        {
            "optgroup": "News",
            "value": "Name"
        },
        {
            "value": "Existing Values"
        }
    ]
}

Example definitions

Check the /examples directory of this repo for example definitions, which also double as test cases for me while developing Scaffolds :)

Future

  • Where there is Sections, there is also Datasources and Events. It would be nice to be able to use Scaffolds on them as well.

  • Look into localStorage, biggest concern I have at the moment is if this information can be shared between domains. Not much use if it can't. Although in development, localhost may just be considered the one domain, so in my environment, localhost/site-1 and localhost/site-2 would have access to the same data. IDK, just dumping, need to look at, it's not critical anyway.