This is may be by design, but I thought it was worth noting.

The function rdf_process uses $variables[$variable_name] to set the content that goes inside the wrapping tag. This works fine for date and created because $variables[$variable_name] is the string of rendered HTML, as it is for most template variables.

However, the content variable and the contained elements in taxonomy_term are arrays. So if we try to use rdf_template_variable_wrapper in rdf_preprocess_taxonomy_term, the HTML output is simply the string 'Array' instead of the actual HTML content.

The content variable is an array when it reaches rdf_process in the following cases:

  • taxonomy_term
  • node (comment, links, and taxonomy)
  • comment_wrapper
  • user_profile

We could potentially 'fix' this by checking to see if '#markup' is set and then operating on '#markup' if it is. This opens up the potential to insert RDF wrapping tags around just the internal markup of a variable if prefix and suffix are set.

We have ways to get around this problem in every case except taxonomy_term, but allowing people to pass unrendered variables in may provide a helpful amount of flexibility.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

I'm attaching a patch and also attaching an example of how this could work in the case of the taxonomy definition. It is probably to late to get the change in for taxonomy definition, but worth looking at.

Anonymous’s picture

Status: Active » Needs review

For this to really work, we would also need to fix #712920: rdf_template_variable_attributes_array doesn't allow you to set value for 'inline' because there could be block level elements in the #markup value.

Status: Needs review » Needs work

The last submitted patch, example_taxonomy-definition.patch, failed testing.

Anonymous’s picture

This one actually works without any changes to the taxonomy-term.tpl.php.

With this patch, the element that is being wrapped can be at any level in the unrendered attributes array, so we can target elements that are within the main content variable.

Anonymous’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, rdf_templatewrapper_712914_4.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
2.1 KB

The check for $variables[$variable_name]['#markup'] was returning the first letter of the string value of $variables[$variable_name] when it was a rendered element.

To prevent this, it now uses is_string to check whether $variables[$variable_name] is a rendered element (HTML string).

Anonymous’s picture

Fixes a small typo in the comments.

effulgentsia’s picture

subscribing. i will review this in more detail later.

rfay’s picture

#8: rdf_templatewrapper_712914_8.patch queued for re-testing.

Anonymous’s picture

Status: Needs review » Needs work

This is now included in #1778226: [META] Fix RDF module, but I believe we won't need it anymore with the changes that Twig will bring.

quietone’s picture

Issue summary: View changes
Parent issue: » #1778226: [META] Fix RDF module