Displaying grouped data with group label subheadings

davidfells's picture

I am trying to recreate this page in a Drupal site here.

I'm trying to determine where and how to modify the view data (if that is in fact what I need to do) to produce this kind of output. I have a CCK type set up w/ all the community information, including state. My view pulls the title and the state name, orders by state asc, title asc. I don't have any idea at this point how I should do this, though it should be noted that I'd like to learn how to do it the "right" way, which is why I'm posting here!

Thanks in advance.

Comments

I resolved this. Not the

davidfells's picture

I resolved this. Not the most beautiful solution but it works.

<?php

$communities
= $variables['view']->result;

$ls = '';
$ts = '';

foreach (
$communities as $c) {
 
$ts = $c->node_data_field_state_field_state_value;
  if (!
$ts) {
    continue;
  }
 
  if (
$ts != $ls) {
    if (
$ls != '') {
      echo
'</ul>';
    }
    echo
'<b>'.$c->node_data_field_state_field_state_value.'</b>';
    echo
'<ul>';
  }
 
  echo
'<li><a href="/node/'.$c->nid.'">'.$c->node_title.'</a></li>'
 
 
$ls = $ts;
}
?>

where did you place this code?

stevepofd's picture

i think i have a similar need, and i am still getting the hang of where these kind of things would go. template.php?

thanks,
steve