Some modules such as rdf.module in core and schema.org in contrib rely on extra attributes to be inserted in the node template. This is how it's done in core's node.tpl.php (note the print statement at the end of the line):

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

The tpls provided in DS inside the layouts directory do not include this print $attributes, even though the variable is available in these tpl files. This makes Display Suite incompatible with RDFa and the schema.org module.

Comments

scor’s picture

Status: Active » Needs review
StatusFileSize
new8.25 KB

Here is a patch which adds the $attributes in all relevant tpls. @about and @typeof are typically the attributes which will get outputted via this variable.

scor’s picture

StatusFileSize
new10.43 KB

forgot some files

swentel’s picture

2 questions:

- Would you mind doing this also for the second branch ? It's a new branch that probably gets an RC this weekend. It's probably going to be easier for that branch, since we print a $layout_attributes which can have custom attributes. Merging the original ones in ds.module should easily add this as support. This could even be a setting on the layout settings page (I somehow prefer to have full control over this).

- Re: the existing patch for first branch: those template files are used potentially by every entity. Is this variable going to be available always ? Maybe core does, but I'm not sure about other entities out there :/ So in a way, I'm a bit hesitant to commit this directly as this might popup notices.

scor’s picture

Status: Needs review » Needs work

Thanks @swentel, that's the kind of guidance I was waiting for. a) I'll roll a patch for 2.x. b) I'll investigate the presence of the variable for any entity. Are these template files tested in any way?

scor’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: Unassigned » scor
Status: Needs work » Needs review
StatusFileSize
new2.85 KB

You were right, patching 2.x was pretty straight forward given that the variable is already present in the tpls. I've added an option for merging these attributes in the UI (defaults to enabled). Is that what you had in mind?

Edit: tried this patch for node, user and comments with both the option on and off, and it works.

swentel’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Status: Needs review » Needs work

Works nicely, thanks! Committed and pushed to second branch. There are no dedicated tests for templates, except for field templates. I'm not sure if we really need them, this won't break that easily in my opinion.

Moving back to first branch.

ezeedub’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new494 bytes

I ended up with two HTML class attributes when $vars['attributes_array'] already had a 'class' item in it. Here's a fix.

ezeedub’s picture

StatusFileSize
new614 bytes

And here's a fix for the fix.

swentel’s picture

Priority: Normal » Critical

Marking critical so I can review this week

swentel’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Priority: Critical » Normal

Thanks ezeedub, commited and pushed!

swentel’s picture

Category: bug » feature
Status: Needs review » Active
ezeedub’s picture

No problem, thanks for this incredible module. And for commit credit. My first! I'm honored it's on DS. :)

farald’s picture

Status: Active » Fixed

Guess it's fixed then? :)

scor’s picture

Status: Fixed » Active

This still needs to be fixed in the 7.x-1.x branch.

adoumas’s picture

Version: 7.x-1.x-dev » 7.x-2.0-rc1

I just update from 7.x.-1.x to 7.x.-2.x and i still cant see the schema attributes on node container.

any ideas?

adoumas’s picture

Issue summary: View changes

fix code markup

aspilicious’s picture

Assigned: scor » bceyssens
Issue summary: View changes

Maybe he can test and finish this for the 7.1 branch.

BarisW’s picture

Just tried with the lastest DS 2.x and schema.org releases but the attributes on fields don't show up.

EDIT: the fields SHOW up, but it's rather cumbersome. I'm using the Expert field settings. To get the attributes, I need to check the 'Add default attributes' checkbox, AND I need to set the class/element on the Field item level (instead of the Field items or Outer wrapper, which we use by default).

It would be awesome if all RDF/Schema attributes were appended by default, so I don't need to make sure I checked the 'Add default attributes' checkboxes.

aspilicious’s picture

We are mixing two things in here.

1) Attributes don't appear on the NODE level
2) Attributes don't appear on the FIELD level

This issue talks about the node level

aspilicious’s picture

Issue summary: View changes
Status: Active » Fixed

And btw, it's perfectly normal that it only works on the field item level. it would be wrong if it worked on the outer wrapper.
I tested the current behaviour on latest dev and it still works fine on he NODE level and fine on the FIELD level once you know how it actually works.

Tried to fix this fast for the 7.x-1.x branch but thats kinda hopeless as it is totally different than the 2.x branch.
Closing this because there won't be a clean and easy fix for the 1.x branch. :(

Status: Fixed » Closed (fixed)

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