Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-28110

As a developer, I want to define attributes for custom tags

    Details

    • Story Points:
      1

      Description

      Abstract

      Add to the custom tags configuration elements to define the tag's attributes at backend level. Those will be used to generate the editing UI for a custom tag in the OE.

      Custom tags

      Any number of attribute can be added to a custom tag:

        <div data-ezelement="eztemplate" data-ezname="externalimage" class="templateClass2" data-ezalign="right">
          <span data-ezelement="ezconfig">
            <span data-ezelement="ezvalue" data-ezvalue-key="src">http://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif</span>
            <span data-ezelement="ezvalue" data-ezvalue-key="height">365</span>
            <span data-ezelement="ezvalue" data-ezvalue-key="width">500</span>
            <span data-ezelement="ezvalue" data-ezvalue-key="alt">flip-flop</span>
            <span data-ezelement="ezvalue" data-ezvalue-key="caption">bistable multivibrator</span>
          </span>
        </div>
      

      They are made available in the tag template in the params variable.

      Configuration

      The custom tag configuration must be added support for the following:

      <tag_name>:
          attributes:
              <attribute_name>:
                  type: <type>
                  required: <false|true>
                  default_value: <default_value>
      

      Initial supported types:

      • "number"
      • "string"
      • "boolean"
      • "choice"

      The types system should be open enough so that:

      • custom types can be defined, including their editing interface and how they're serialized
      • in a later iteration, fieldtypes can be used as attributes types (this needs to be better explored in a spike)

      Label and description

      An attribute needs to have a human readable, translatable label as well as a description. These should be implemented using the i18n system, with the identifier as the prefix: richtext_tag_<identifier>label, richtext_tag<identifier>_description.

      Backend validation

      Attributes posted for a custom tag in XML should be validated for :

      • existence: an error should occur if a custom attribute is set but not defined in the configuration).
      • required status: if a required attribute is missing, an error should be thrown.
      • type: if an attribute doesn't have the right type, an error should be thrown.

        Issue Links

          Activity

          Hide
          Bertrand Dunogier added a comment -

          After digging through RichText, it appears that we might be able to store custom tags attributes already:

            <div data-ezelement="eztemplate" data-ezname="externalimage" class="templateClass2" data-ezalign="right">
              <span data-ezelement="ezconfig">
                <span data-ezelement="ezvalue" data-ezvalue-key="src">http://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif</span>
                <span data-ezelement="ezvalue" data-ezvalue-key="height">365</span>
                <span data-ezelement="ezvalue" data-ezvalue-key="width">500</span>
                <span data-ezelement="ezvalue" data-ezvalue-key="alt">flip-flop</span>
                <span data-ezelement="ezvalue" data-ezvalue-key="caption">bistable multivibrator</span>
              </span>
            </div>
          

          This should be sufficient to store any custom attribute.

          Show
          Bertrand Dunogier added a comment - After digging through RichText, it appears that we might be able to store custom tags attributes already: <div data-ezelement="eztemplate" data-ezname="externalimage" class="templateClass2" data-ezalign="right"> <span data-ezelement="ezconfig"> <span data-ezelement="ezvalue" data-ezvalue-key="src">http://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif</span> <span data-ezelement="ezvalue" data-ezvalue-key="height">365</span> <span data-ezelement="ezvalue" data-ezvalue-key="width">500</span> <span data-ezelement="ezvalue" data-ezvalue-key="alt">flip-flop</span> <span data-ezelement="ezvalue" data-ezvalue-key="caption">bistable multivibrator</span> </span> </div> This should be sufficient to store any custom attribute.
          Hide
          Bertrand Dunogier added a comment -

          I confirm that the XHTML above will be stored with the attributes. In the rendering template, they will be available in the params array, with their data-ezvalue-key as the key.

          This means that this story isn't needed, and we can move on to implementing the definition of those attributes.

          Show
          Bertrand Dunogier added a comment - I confirm that the XHTML above will be stored with the attributes. In the rendering template, they will be available in the params array, with their data-ezvalue-key as the key. This means that this story isn't needed, and we can move on to implementing the definition of those attributes.
          Hide
          Bertrand Dunogier added a comment -

          Ping Łukasz Serwatka: this is ready to be reviewed by the relevant lead developers.

          Show
          Bertrand Dunogier added a comment - Ping Łukasz Serwatka : this is ready to be reviewed by the relevant lead developers.
          Hide
          Bertrand Dunogier added a comment - - edited

          Good catch. But do you think that we could just go with a textfield for the time being ? If I recall correctly, the style thing was applicable to most XML nodes in legacy. It would probably make as much sense for eZ Platform, but it also goes beyond custom tags. With a text input, we can support classes without implementing choice.

          But if you wanna go for it, and are confident it won't take precedence over otherwise required features, I'm fine with it. If you confirm that, I'll add it to the specs.

          By the way, Łukasz Serwatka, I remember you mentioning FieldTypes in regards to those attributes types. We haven't had a chance to discuss it, but I have also thought of that, and would like to talk about it before we add more types with this custom approach. Just to make sure we agree, the idea is that we could use existing fieldtypes (ezselection, ezstring, ...) as types for custom tags attributes.

          Show
          Bertrand Dunogier added a comment - - edited Good catch. But do you think that we could just go with a textfield for the time being ? If I recall correctly, the style thing was applicable to most XML nodes in legacy. It would probably make as much sense for eZ Platform, but it also goes beyond custom tags. With a text input, we can support classes without implementing choice. But if you wanna go for it, and are confident it won't take precedence over otherwise required features, I'm fine with it. If you confirm that , I'll add it to the specs. By the way, Łukasz Serwatka , I remember you mentioning FieldTypes in regards to those attributes types. We haven't had a chance to discuss it, but I have also thought of that, and would like to talk about it before we add more types with this custom approach. Just to make sure we agree, the idea is that we could use existing fieldtypes (ezselection, ezstring, ...) as types for custom tags attributes.
          Hide
          Andrzej Longosz added a comment - - edited
          Show
          Andrzej Longosz added a comment - - edited PR for Kernel: https://github.com/ezsystems/ezpublish-kernel/pull/2219 PR for eZ Platform Admin UI: https://github.com/ezsystems/ezplatform-admin-ui/pull/320
          Show
          Michał Szołtysek added a comment - PR for Kernel merged in: https://github.com/ezsystems/ezpublish-kernel/commit/77d9d35e75f337c5ee2de1323a4ec94cbacc6ce2 PR for eZ Platform Admin UI merged in: https://github.com/ezsystems/ezplatform-admin-ui/commit/4f4a6fbcc4a95f99ad6cc0f5eb89767197d87679

            People

            • Assignee:
              Unassigned
              Reporter:
              Bertrand Dunogier
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Agile