martin-wessel-topfloor / Field-Markup

A Drupal 7 module that extends Display Suite by exposing the Expert field markup settings in a JSON file.
0 stars 0 forks source link

Change modifier:key format for bundle: etc #2

Open martin-wessel-topfloor opened 9 years ago

martin-wessel-topfloor commented 9 years ago

Using a modifier:key structure in what should be a JSON key breaks the rules. Switch to a proper structure:

"field-name" : {
  "bundle" : {
    "page" : {
...
    },
    "product": {
...
    }
  },
  "view-mode" : {
    "teaser: {
...
    }
  }
}

And called in code with $markup['bundle']['page'] rather than $markup['bundle:page']. That should also help organize the JSON a little better.

martin-wessel-topfloor commented 9 years ago

Note that this will break backwards compatibility

martin-wessel-topfloor commented 8 years ago

This breaks compatibility only in the sense that those keys would be ignored and the field definition would not be processed.

It might be possible to keep backwards compatibility if the tf_functions_load_json function is updated to allow altering the array before it is saved. A hook could be implemented in field_markup that scans through the array looking for a modifier:key structure and converting it to a modifier : { key : { structure.

It is important to note that since modifier is now a key, it must be unique inside the field definition. The source array may have several modifier:key keys and these must be combined into a modifier : { key : {...}, key : {...} } type structure.

martin-wessel-topfloor commented 8 years ago

Note also that bundle is being renamed to content-type and a separate hook should be written to make that change in existing JSON files . The hook would also need to search for content-type in case that other hook runs first.