Updated: Comment #N
Problem/Motivation
rdf_preprocess_taxonomy_term() adds its metadata RDFa markup to the <head> element of the HTML document. In #1323830: Place title RDFa metadata inside entity HTML element we established that it was better to place this markup inside the entity output itself, in the wrapping element and in title suffix.
Proposed resolution
Follow a similar approach as the one used in rdf_preprocess_node(), place the taxonomy term type (@typeof) and term url (@about) on the wrapping HTML element, and the term name (@property) in a metadata element attached to title_suffix.
In the end, we should end up with these 3 variables set:
$variables['attributes']['about'] = ...
$variables['attributes']['typeof'] = ...
...
$variables['title_suffix']['rdf_meta_title'] = ...
Remaining tasks
patch
User interface changes
n/a
API changes
n/a
Comments
Comment #1
djevans commentedComment #2
dman commented(edited description for code tag)
Comment #3
djevans commentedPatch attached.
Comment #4
djevans commentedComment #5
scor commentedThis is no longer accurate. The type is set above in @typeof.
Feel free to mimic the same structure/comments as in rdf_preprocess_node(), and move $name_field_mapping = down right before you do $name_attributes = ... You should also do an if() there. See how rdf_preprocess_node() does it.
also, no need to use url(), $term now has a url() method.
Comment #6
djevans commentedOk, just seen the url() method that Term inherits from Drupal\Core\Entity.
I've rearranged the code into more logical chunks as suggested. I've also corrected the comments and thrown in checks that $bundle_mapping['types'] and $name_field_mapping['properties'] aren't empty, all after the style of rdf_preprocess_node().
Comment #7
scor commentedCode looks good, we just need to do some manual testing and see what the markup is before and after the patch, to see that the new markup went where it was intended to go...
Comment #8
seiplax commentedIt works. Applied the patch and this is the generated code:
This html-tag is also removed from the header
<meta about="/taxonomy/term/1" typeof="schema:Thing" property="schema:name" content="My Test Tag" /><link title="RSS - My Test Tag" type="application/rss+xml" href="http://d8.local:8083/taxonomy/term/1/feed" rel="alternate" />Comment #9
scor commentedLooks good, thanks @djevans and @seiplax for testing.
Comment #11
lokapujyaReroll.
Comment #12
scor commentedpatch is empty.
Comment #13
lokapujyaReroll. Trying again.
Comment #14
scor commentedThe previous patch in #6 had removed that line/comment.
Comment #15
lokapujyare-removed the comment.
Comment #16
scor commentedLooks good, thanks again Jamie!
Comment #17
alexpottCommitted 36596e3 and pushed to 8.x. Thanks!