When a field is in a fieldgroup, it displays twice when viewing the node. I think the field gets parsed once for the normal node and then again when the fieldgroup is called. are other people seeing this or did i miss a setting?

Comments

yched’s picture

This must be something in your theme - could you try switching back to Garland and see if there is still an issue ?

You are probably using a custom node-my_type.tpl.php to theme the nodes ? Pasting it here could help.

jyamada1’s picture

hm. still the same duplicate fields after: trying zen and garland themes, turning off my "template.php" module and various other modules, clearing the cache after each change.

i am not using a custom node-content_myfield.tpl.php for the content types in which i am seeing this effect. i do have a node.tpl.php in my theme directory, little changed if at all yet, and it's pasted below. again, though, switching to other themes didn't help, so this can't be the problem. any other ideas where this duplication could be happening?

node.tpl.php
<div class="<?php print $node_classes ?>" id="node-<?php print $node->nid; ?>">
  <?php if ($page == 0 && $title): ?>
    <h2 class="title">
      <a href="<?php print $node_url ?>"><?php print $title; ?></a>
    </h2>
  <?php endif; ?>

  <?php if ($picture) print $picture; ?>  
  
  <?php if ($submitted): ?>
    <span class="submitted"><?php print t('Posted ') . format_date($node->created, 'custom', "F jS, Y") . t(' by ') . theme('username', $node); ?></span> 
  <?php endif; ?>

  <?php if (count($taxonomy)): ?>
    <div class="taxonomy"><?php print t(' in ') . $terms ?></div>
  <?php endif; ?>
  
  <div class="content">
    <?php print $content; ?>
  </div>
  
  <?php if ($links): ?>
    <div class="links">
      <?php print $links; ?>
    </div>
  <?php endif; ?>
</div>

fago’s picture

Do you have some other modules installed that might cause that?

jyamada1’s picture

still can't figure this one out.

i've reinstalled garland and disabled all of the modules i could that seem to have an effect on cck. of course, i had to leave some of the cck field modules so i could see the content. disabling fieldgroup gets rid of all the fields (duplicates too) that are in fieldgroups.

bltinnel’s picture

I've seen the same thing but only when using Firefox (Windows or Mac OS/X) or Safari (Mac OS/X). When I use IE7 on Windows everything looks fine.

bltinnel’s picture

Sorry about that. I wasn't watching what I was doing. It looks like the difference is logging on as the administrator vs. logging on as a "normal" user. The administrator lists the fields correctly, the normal users lists them twice. At least that is what is happening to me.

bltinnel’s picture

Ok, a bit more info. In my case, the SQL being generated to get the values for the field is:

SELECT node_data_field_phonenum.field_phonenum_value AS value FROM {node} node
LEFT JOIN {content_field_phonenum} node_data_field_phonenum ON node.vid = node_data_field_phonenum.vid
WHERE node.nid = 329
ORDER BY node_data_field_phonenum.delta

Which returns one row when I run it. However, after being passed through db_rewrite_sql it becomes:

SELECT node_data_field_phonenum.field_phonenum_value AS value FROM {node} node
LEFT JOIN {content_field_phonenum} node_data_field_phonenum ON node.vid = node_data_field_phonenum.vid
INNER JOIN {node_access} na ON na.nid = node.nid
WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 2 AND na.realm = 'term_access') OR (na.gid = 4 AND na.realm = 'term_access'))) AND ( node.nid = 329 )
ORDER BY node_data_field_phonenum.delta

The added INNER JOIN and additional WHERE clauses return 2 rows from node_access which causes the duplicate fields to be returned. Is this a CCK issue or a Node issue?

bltinnel’s picture

Not sure if this is useful, but I fixed this on my site by changing the generated SQL to:

SELECT DISTINCT(node_data_field_phonenum.delta), node_data_field_phonenum.field_phonenum_value AS value FROM {node} node
LEFT JOIN {content_field_phonenum} node_data_field_phonenum ON node.vid = node_data_field_phonenum.vid
WHERE node.nid = 329
ORDER BY node_data_field_phonenum.delta

I did this by changing a line in function content_views_field_handler_group from

$query = "SELECT ". implode(', ', $query_columns) .

to

$query = "SELECT DISTINCT(node_data_$field[field_name].delta), ". implode(', ', $query_columns) .

In my case there is only one column being queried (phonenum), but I think this fix will work for multiple columns. Hopefully someone with much more knowledge about CCK will look at this and determine if it is safe.

dopry’s picture

Status: Active » Closed (fixed)

cannot reproduce on latest 1.x