When using the w3c HTML validator. I noticed that classes and id's are rendered twice.

<div class="block block-nodeblock block-33 block-nodeblock-33 even block-without-title" id="block-nodeblock-33">
  <div class="block-inner clearfix">
                
    <div class="content clearfix">
      <div id="node-33" class="node node-block clearfix" class="node node-block node-published node-not-promoted node-not-sticky author-root even clearfix" id="node-block-33">

When I change in node-nodeblock-default.tpl.php.

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

to

<div <?php print $attributes; ?>>

It only removes the first duplicates and not the one from the render($content).

Comments

Tom Robert’s picture

Issue summary: View changes

update

Tom Robert’s picture

Issue summary: View changes

update

Johnny vd Laar’s picture

Status: Active » Postponed (maintainer needs more info)

By default nodeblock doesn't have such behavior. Does your site have some preprocess_node function that sets the attributes array?

Also the node.tpl.php has the same div tag.

Tom Robert’s picture

The problem occurs when using nodeblock and the omega theme.
When using the omega theme it makes is own implementation of node.tpl.php and uses a few preprocess functions.

The nodeblock template is a copy of the original node.tpl.php with an extra check to see if it is a nodeblock.

Omega executes the preproccess functions but then it implemented in a default node.tpl.php which results in duplicate classes and id's.

Would it be possible that nodeblock implements node.tpl.php used by the system and not a copy the default node.tpl.php and maybe just try a preproccessing function to filter out the title if necessary. I think it would be robuster for people who use their own node.tpl.php with preprocessing functions. Because we use the combination omega and nodeblock a lot. The temporary fix now is to use omages node.tpl.php in the node--nodeblock.tpl.php with the extra $nodeblock variable.

Johnny vd Laar’s picture

Category: bug » feature
Status: Postponed (maintainer needs more info) » Needs work

The default node.tpl.php removes the title via the $page variable. I don't think it's correct to set this flag with a preprocess function. So I think we do need a special node template for this module. So I don't know how to do this in a nice way.

I'm marking this as needs work and as a feature request such that someone who needs this can create a patch.

Darin Clemmer’s picture

In order to get rid of the duplicate class and id attributes when using nodeblock + omega (We are using the OpenPublic distribution), I made the following changes:

Change line #16 from 
THIS: 
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

TO THIS:
<div <?php if(!$attributes) { ?>class="<?php print $classes; ?>"<?php } else { print $attributes; }?>>

-- AND --

Change line #34 from 
THIS:
<div class="content"<?php print $content_attributes; ?>>
TO THIS:
<div <?php if(!$content_attributes) { ?>class="content"<?php } else { print $content_attributes; }?>>

I have not found any ill effects from doing this, but I have not done much testing yet either.

Johnny vd Laar’s picture

Such logic shouldn't be in template files but inside the preprocess file. I also don't want to make to much Omega specific code. Perhaps it'll be sufficient to just mention it inside the README.txt that you need to do some changes for the Omega theme.

steverweber’s picture

Wish I seen this thread before wasting so much time reviewing nodeblock code.
I also use the omega theme..

Johnny vd Laar’s picture

Status: Needs work » Closed (works as designed)
Johnny vd Laar’s picture

Issue summary: View changes

udpate