Problem/Motivation
#1778122: Enable modules to inject attributes into field formatters, so that RDF attributes get output is switching all field formatters to use the new RDFa syntax where the mappings for each field are defined in the main entity (e.g. the mapping for a text field is defined in the mappings of the node). In the case of a taxonomy term for example, the mapping of the term (e.g. schema:about) is defined in the node, but the mappings for the term type and the term title are defined in the term mappings, not in the original node mappings. Drupal 7 currently supports type + title for taxonomy terms.
Proposed resolution
Extend rdf_entity_prepare_view() to add the additional mappings for type and title in $property->html_data_attributes
for the appropriate fields (taxonomy term and entity reference), and add these attributes in the relevant formatters.
Remaining tasks
patch
User interface changes
none
API changes
none other than the markup change
Comment | File | Size | Author |
---|---|---|---|
#3 | 2072791_3_taxonomy_term_extra_rdf.patch | 49.11 KB | scor |
#3 | 2072791_3_taxonomy_term_extra_rdf-for-review.txt | 7.16 KB | scor |
#1 | 2072791_1_taxonomy_term_extra_rdf.patch | 44.88 KB | scor |
#1 | 2072791_1_taxonomy_term_extra_rdf-for-review.txt | 7.29 KB | scor |
Comments
Comment #1
scor CreditAttribution: scor commentedI wrote a first prototype using the flexibility of the field items _attributes introduced by #1778194-10: RDF module can't handle compound fields. Here I'm using the fact that _attributes is an array that implementations of hook_entity_prepare_view() can populate as needed, in particular if the field is of type taxonomy_term_reference, extra sets of attributes are added for the type and name of the taxonomy term, so that the formatter can add these attributes directly in the HTML output.
Comment #3
scor CreditAttribution: scor commentedreroll
Comment #6
Mile23Just a heads-up: core/modules/rdf/src/Tests/EntityReferenceFieldAttributesTest.php contains a @todo about this issue. The patch in #3 does not seem to address it.
Comment #17
quietone CreditAttribution: quietone at PreviousNext commentedThis was a bugsmash random target yesterday with longwave, borisson_ and larowlan present. The agreement was that this is a task and moves to the contrib project.
I am doing that now.