Problem/Motivation
Some advanced markup techniques—like that provided by schema.org—require field wrappers to have custom attributes, rather than just classes. This is becoming an increasingly important SEO issue as search engines give preference to sites providing this data. However, there is currently no simple way to add these attributes to fields without creating numerous custom templates or field formatters.
Proposed resolution
When using the Expert field template in Display Suite, allow each element to include an arbitrary number of custom attributes.
User interface changes
The simplest and most flexible way to accomplish this would be to provide an "Attributes" text field for each element, just like is done now for classes. Site builders could then type in whatever they want and the whole thing could be inserted into the element tag.
Comment | File | Size | Author |
---|---|---|---|
#9 | 1388008.9-display-suite-expert-attributes.patch | 20.9 KB | mrfelton |
#8 | 1388008.8-display-suite-expert-attributes.patch | 19.98 KB | mrfelton |
#7 | 1388008-display-suite-expert-attributes.patch | 5.64 KB | mrfelton |
Comments
Comment #1
jstollerJust a thought, but given the semantics for attributes are somewhat more involved than for classes, it might be nice to have some basic validation on the field. I wouldn't validate the attributes themselves, since this should be about increasing flexibility, but we should probably make sure every opening quote has a corresponding closing quote. Basically, it would be nice if we prevented someone from taking down their entire site with one malformed attribute.
Comment #2
mrfelton CreditAttribution: mrfelton commentedWe have a need for this too, in order to be able to add named anchors to specific elements.
Comment #3
swentel CreditAttribution: swentel commentedMoving to 7.x-2.x branch, I'll add that this weekend.
Comment #4
swentel CreditAttribution: swentel commentedmarked #1471642: Add node $title_attributes in $content_attributes field title as a duplicate. Still in doubt how to handle this:
- a) add a checkbox to print out attributes in general (so the generated ones)
- b) add a textfield to add custom attributes
- c) have both options
Comment #5
swentel CreditAttribution: swentel commentedAlso, can we fix it for the title or not (see the duplicate issue)
Comment #6
mrfelton CreditAttribution: mrfelton commentedComment #7
mrfelton CreditAttribution: mrfelton commentedHere is the first part, which does the attributes. Still need to add a checkbox for the default attributes and include them in the output if checked.
Comment #8
mrfelton CreditAttribution: mrfelton commentedUpdated patch, adds the additional options, and rearranges the form into fieldsets and adds state api implementation to make it 'slightly' more manageable. The UI feels very heavy though when all the options are enabled.
Also, the implementation of the default attributes needs checking, as I'm not 100% clear which element these are supposed to be applied to.
Comment #9
mrfelton CreditAttribution: mrfelton commentedOops, the hide colon option was broken. Updated patch fixes that.
Comment #10
swentel CreditAttribution: swentel commentedLooks that this is missing default classes checkbox, no ? Also I don't see the label element and classes don't appear in the UI either.
(note, the latest commit moved a lot of code around in folders)
Comment #11
swentel CreditAttribution: swentel commentedMarked #1529730: add prefix and suffix to expert field template to here
Let's do it all together!
Comment #12
loominade CreditAttribution: loominade commented#1529730: add prefix and suffix to expert field template assumes also to add prefix and suffix + their wrappers in this issue
edit:
oh, sorry
Comment #13
swentel CreditAttribution: swentel commentedCommitted a first part for adding attributes + tests for it. Note it's not using the fieldset layout for now. Still needs the checkboxes for default classes and attributes and the even/one class on the field item wrapper
Pre- and suffixes will be held out for now.
Comment #14
swentel CreditAttribution: swentel commentedThis has all been committed, reassigning to jyve so he remembers to look a bit at the CSS because expert just exploded :)
Comment #15
mrfelton CreditAttribution: mrfelton commentedAwesome.
p.s.
;)
Comment #17
rodrigoaguileraSo theres is no way to add affixes to a field?
maybe you can point me to another module