Download & Extend

$node->content[field_fieldname] not working

Project:Content Templates (Contemplate)
Version:7.x-1.x-dev
Component:Code
Category:support request
Priority:critical
Assigned:Unassigned
Status:active

Issue Summary

I'm using contemplate with jstools tabs module. I'm trying to change the layout of fields inside each fieldgroup, so I thought it to be the solution I was looking for.

I'm trying to change (first) the way the Body view looks like. I found the post in http://groups.drupal.org/node/8359 to be very useful to get the following code for the template:

<div id="tabs-1" class="drupal-tabs">
<ul class="anchors">
<li><a href="#tabs-tabset-1">Tab1</a></li>
<li><a href="#tabs-tabset-2">Tab2</a></li>
</ul>
<div id="tabs-tabset-1" class="fragment">
<h2 class="drupal-tabs-title">Tab 1</h2>
<?php print $node->content['field_somefield']?>
</div>
<div id="tabs-tabset-2" class="fragment">
<h2 class="drupal-tabs-title" >Tab 2</h2>
<?php print $node->content['field_someotherfield']?>
</div>

As can be seen, I'm trying to show the $node->content['field_XXX'] variables (which, as the 'body variables' link states, are available) but nothing is printed. But if I replace them with something like $node->field_XXX[0]['view'], this value is shown.

Is this an issue? or am I doing something wrong?

Comments

#1

Status:active» closed (fixed)

silly me! I forgot to prepend ['fieldgroup_tabs']['group_groupname'] before ['field_XXX']. Now it works like a charm :)

Mental note: have it in mind if you're working with cck fieldgroup tabs

#2

Version:5.x-2.04» 7.x-1.x-dev
Category:bug report» support request
Status:closed (fixed)» active

Hi,

I have the same problem and your solution doesn't work for me.

I work with Drupal 7.

I have custom fields to describe me content.

If I do that, it's work :

<?php
$node
->field_custom[$node->language][0]['value'] = "foo";
?>

But if I want to change my field name or to add a field without change my module code, I think it can be usefull to use $node->content
But those 2 solutions don't work :

<?php
$node
->content['field_custom'][$node->language][0]['value'] = "foo";
?>

<?php
$node
->content['fieldgroup_tabs']['group_desc']['field_custom'][$node->language][0]['value'] = "foo";
?>

Any ideas

Thanks

Axmo