http://justkansas.com - I have most of my directory roughed in. I am using CCK, Taxonomy Context, and Views. I am working on a better front page that will feature forums, directory and other features but its a start.

I would like to find a way to theme the content based o the author's role. I will want to charge, in the future, for an enhanced listing - the 4 quick links and logo or picture.

Comments

michelle’s picture

It's very very clean and well layed out. The category page looks eerily familiar, too. :)

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

toma’s picture

Nice work, i try to make the directory with no success "http://shellmultimedia.com/articles/directory-browse-page" always same problem importing views "Unable to get a view out of that"

Can you help us the creator of Kansas directory! may be a step by step how to create the views !

Thanks
---
Biladi
http://www.biladi.ma

llizards’s picture

Here is my export of my directory view. Creating this view displays a blank page for me until I added the coding into the template.tpl.php. The credit goes Michelle for her tutorials

View:

  $view = new stdClass();
  $view->name = 'directory_browse';
  $view->description = 'Browsable directory';
  $view->access = array (
);
  $view->view_args_php = '// Always use 3 as the augment since that\'s the directory\'s taxonomy
if (!$args[0]) {
  $args[0] = 3;
}';
  $view->page = TRUE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'panels_threecol_term';
  $view->url = 'kansas_directory';
  $view->use_pager = FALSE;
  $view->nodes_per_page = '0';
  $view->sort = array (
    array (
      'tablename' => 'node',
      'field' => 'sticky',
      'sortorder' => 'DESC',
      'options' => '',
    ),
    array (
      'tablename' => 'node',
      'field' => 'title',
      'sortorder' => 'ASC',
      'options' => '',
    ),
  );
  $view->argument = array (
    array (
      'type' => 'vocid',
      'argdefault' => '1',
      'title' => '%1',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
    array (
      'type' => 'taxid',
      'argdefault' => '6',
      'title' => '%1 - %2',
      'options' => '9',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
  );
  $view->filter = array (
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node);
  $views[$view->name] = $view;

Template:

// Start Panel Views
// BEGIN Override the browse directory view (panels by term) theming
function phptemplate_views_bonus_panels_byterm_summary_directory_browse($view) {
  
  drupal_add_css(drupal_get_path('module', 'views_bonus') .'/views_bonus.css');
  
  // argument 0 must be a vocabulary ID
  $vid = $view->args[0];
  
  // Get the taxonomy tree from the argument to the view
  $tree = taxonomy_get_tree($vid);
  
  // group terms with their parent
  foreach ($tree as $term) {
    $cnt = taxonomy_term_count_nodes($term->tid);

    if ($term->depth == 0) {
      // Top level category. Add the "all" to the URL to show all subterms when the link is clicked
      $txt = array($prefix. l($term->name . " ($cnt)", "taxonomy/term/$term->tid/all")); 
      $parent_tid = $term->tid;
      $groups[$parent_tid]['header'] = $txt;
    } else {
      // This bit is a pseudo tagadelic for the terms. It takes the number of nodes for a term and divides
      // it by 5 and then uses just the whole number part. If a term has at least one node, it gets a 1. If 
      // a term has more than 25 nodes, it stays at 5. These numbers are then used to add an extra class of
      // "sizedterm-N" where N is 0-5 that can be styled in CSS to make the terms look different based on
      // the number of nodes in the term.
      $sizeclass = floor($cnt/5);
      if ($sizeclass == 0 && $cnt > 0) {
        $sizeclass = 1;
      }
      if ($sizeclass > 5) {
        $sizeclass = 5;
      }
      
      $txt = array('<span class="sizedterm-' . $sizeclass . '">' . l($term->name . " ($cnt)", "taxonomy/term/$term->tid") . '</span>'); 
      $groups[$parent_tid]['rows'][] = $txt;
    }    
  }
  
  // Spread the across 2 columns
  $content = array();
  $i=0;
  foreach ($groups as $group) {
    if ($i % 2) {
      $section = 'left';
    } else {
      $section = 'right';
    }

    // Create a comma separated list of subterms
    $subterms = array();
    foreach ($group['rows'] as $subterm) {
      array_push($subterms, $subterm[0]);
    }
    $subterms = implode(", ", $subterms);
    
    $content[$section] .=  '<div style="display:block;"><h3>' . $group['header'][0] . "</h3>" . $subterms . "</div>";
    
    $i++;
  }  
  return panels_print_layout('twocol', $content);
}

// END Override the browse directory view (panels by term) theming
// END Panel Views
andrewblack’s picture

thanks for sharing

llizards’s picture

I found your tutorial a big help.

toma’s picture

Thanks for your reply, i try to setup the same and get the first look directory to work, click to the taxonomy all link doesn't display the node's, i need to click the term and it display

Art (1) ===> this is the taxonomy/all link doesn't display the node with Movies
- Movies (1) ==> display the node with movies

in your website link /taxonomy/term/980/all it show all the subterms and links, not for me! is it the same code !?? also in tutorial website it work like yours

---
Biladi
http://www.biladi.ma

llizards’s picture

I am also using the taxonomy content module, this is what diplays all the sub terms and nodes...

toma’s picture

I can't any module with that name! can your provide a link to the module! please
---
Biladi
http://www.biladi.ma