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

djevans’s picture

Assigned: Unassigned » djevans
dman’s picture

Issue summary: View changes

(edited description for code tag)

djevans’s picture

Patch attached.

djevans’s picture

Status: Active » Needs review
scor’s picture

Status: Needs review » Needs work
+++ b/core/modules/rdf/rdf.module
@@ -529,17 +529,17 @@ function rdf_preprocess_taxonomy_term(&$variables) {
   $name_field_mapping = $mapping->getPreparedFieldMapping('name');
...
+  // Add the RDF type of the term and the term name in a <span> tag.

This 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.

djevans’s picture

Status: Needs work » Needs review
StatusFileSize
new1.72 KB

Ok, 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().

scor’s picture

Issue tags: +Needs manual testing

Code 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...

seiplax’s picture

Status: Needs review » Reviewed & tested by the community

It works. Applied the patch and this is the generated code:

<div class="content">
          <div id="taxonomy-term-1" data-quickedit-entity-id="taxonomy_term/1" class="taxonomy-term vocabulary-tags contextual-region" about="/taxonomy/term/1" typeof="schema:Thing">
  
    <div data-contextual-id="taxonomy_term:taxonomy_term=1:changed=1402079136"></div>  <span property="schema:name" content="My Test Tag" class="rdf-meta"></span>

  <div class="content">
    <div class="field field-taxonomy-term--description field-name-description field-type-text-long field-label-hidden" data-quickedit-field-id="taxonomy_term/1/description/und/full">
    <div class="field-items">
          <div class="field-item" property="schema:description"><p>desc of term</p></div>
      </div>
    </div>
  </div>

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" />

scor’s picture

Looks good, thanks @djevans and @seiplax for testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: rdf-taxonomy-term-rdfa-output-2225965-6.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
StatusFileSize
new0 bytes

Reroll.

scor’s picture

Status: Needs review » Needs work

patch is empty.

lokapujya’s picture

Status: Needs work » Needs review
StatusFileSize
new1.89 KB

Reroll. Trying again.

scor’s picture

Status: Needs review » Needs work
+++ b/core/modules/rdf/rdf.module
@@ -527,22 +527,28 @@ function rdf_preprocess_comment(&$variables) {
   // Adds the RDF type of the term and the term name in a <meta> tag.

The previous patch in #6 had removed that line/comment.

lokapujya’s picture

Status: Needs work » Needs review
StatusFileSize
new627 bytes
new1.89 KB

re-removed the comment.

scor’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks again Jamie!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 36596e3 and pushed to 8.x. Thanks!

  • alexpott committed 36596e3 on 8.x
    Issue #2225965 by lokapujya, djevans | scor: Move taxonomy term RDFa...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.