Hey guys, to get straight to the point, what I've been trying to figure out is out to create a list of fields that are sorted into a specific field group.

I have this code defined in a custom PHP block which shows up on a specific node. What I'd like to do is:

Get Fields in "group_rentalinfo" and display them like

<ul>
<li><span>Field Title:</span> Field content </li>
<li><span>Field2 Title:</span> Field2 content </li>
<li><span>Field3 Title:</span> Field3 content </li>
</ul>

So basically, grab the fields from a specific group of fields, and list their title and content in that fashion. This is the code I have so far:

<?php

if (arg(0) == 'node' && is_numeric(arg(1))) {
  if ($node = node_load(arg(1))) {
    if ($node->type == 'rental') {
	echo "<ul>";	
	if ($node->field_availability[0]['value']) :
    print "<li><span>Available:</span>".$node->field_availability[0]['value']."</li>";
	endif;	
	echo "</ul>";
    }
  }
}

?>

I can't seem to figure out how to print the field's title anyways. I've tried:

<?php print $node->field_availability[0]['label']; ?>
and that does not work at all, which theoretically it should.

Thanks for any help!

Comments

Axertion’s picture

Is it not possible to display all fields within a group? Whats the point of grouping other than sorting it for the edit page?

sirviejo’s picture

I created a module for D7 that adds a new formater for field_group to build lists (ordered and unordered)

http://drupal.org/sandbox/sirviejo/1710684

There you can see how i mange to check all the child elements.