hi,
I'm using 7.x-1.0-alpha6 with an omega 7.x-3.1 subtheme and I see node titles broken in teaser display mode, something like this:

After looking at page source I found some html tag inside the title attribute of html anchor around title (when displaying in teaser mode).
<h2 property="dc:title" datatype="" class="node-title"><a href="/product/fere-hos-importunus-loquor-pneum-suscipit" title="<div data-edit-id="node/128/title/und/teaser"><div class="field-item">Fere Hos Importunus Loquor Pneum Suscipit</div></div>"><div data-edit-id="node/128/title/und/teaser"><div class="field-item">Fere Hos Importunus Loquor Pneum Suscipit</div></div></a></h2>
I found that the problem is wrong way used to wrap title in some html wrapper inside function theme_edit_wrap_field($variables). you added your html wrapper tags, directly to title string:
return '<'. $el . drupal_attributes($variables['attributes']) . '><' . $el .' class="field-item">' . $variables['value'] . '</' . $el . '></' . $el . '>';
so variable $title in file sites/<domain>/themes/omega/omega/templates/node.tpl.php become non-plain text, then themes like omega using node title as title attribute of anchor wrapper in teaser display mode will generate wrong html codes, and cause something broken like this. for example omega uses this code:
<h2<?php print $title_attributes; ?>><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
To prevent this problem I suggest use variables $title_prefix and $title_suffix instead appending and prepending tags to $title.
| Comment | File | Size | Author |
|---|
Comments
Comment #1
nod_Yeah I see the issue, title prefix and suffix doesn't work well though. I had to do it like that :(
Comment #2
wim leers#1: Can you clarify? Why are
$title_(pre|suf)fixnot viable?Comment #3
nod_because on that case what is wrapped is different to what is rerendered.
Comment #4
Manovra76 commentedI have the same problem, in the node teaser title with tag to full node, the new attributes broken html. I use this work around
file: edit.module
function: theme_edit_wrap_field
row: 669
replace:
------------
return '<'. $el . drupal_attributes($variables['attributes']) . '><' . $el .' class="field-item">' . $variables['value'] . '';
------------
with
------------
if(strpos($variables['edit_id'],'title')===FALSE) {
return '<'. $el . drupal_attributes($variables['attributes']) . '><' . $el .' class="field-item">' . $variables['value'] . '';
} else {
return '<'. $el . '><' . $el .' >' . $variables['value'] . '';
}
------------
is not the solution, but the html is not broken.
Comment #5
wim leersSo… how are we ever going to succeed in solving this? AFAICT this is not a solvable problem? It's due to insufficient abstraction requirements in D7. I think the only conceivable solution is to add a work-around for this in Edit itself?
Comment #6
wim leersD'oh, it's actually much simpler. The only time where this is a problem, is where a team also prints the title as an attribute (i.e. when it assumes the title does not contain any HTML). That's a poor assumption to make. E.g. some titles may contain
<em>, which is perfectly sensible. When used in an attribute, any and all HTML should be stripped.So, instead of:
please use this instead:
Or, more specifically:
→
(Ideally, you would handle this in theme preprocess functions.)
Problem solved, correct output guaranteed.
Fix upcoming (I need to link to this comment), in the form of documentation in the README.
Comment #7
wim leershttp://drupalcode.org/project/edit.git/commit/eab785a