Is there a generic way to link to a specific node type, the way /taxonomy/page/or/3 links to a specific taxonomy term? Specifically, I'd like to create a navigation link "News" pointing to a list of nodes of the flexinode type "news".

Thanks!

Comments

matteo’s picture

On my sandbox you'll find an hacked module taxonomy module that lets you add a node type filter.
The syntax is
/taxonomy/page|feed/and|or/item1,item2/nodetype1,nodetype2

if you omit nodetypes, all nodetype is assumed; if you specify it, noe_types are filtered in or.
This module works fine on Drupal 4.4.x, but also manages terms and vocabulary translations, and the two patches are not separate.
Follow all 'matteo' string to understand where I hacked the code.

http://cvs.drupal.org/viewcvs/contributions/sandbox/matteo/modules/Drupa...

Hope it helps,
I would like this feature to be added to Drupal Core....

CIAO
Matteo
mailto:webmaster@cantincoro.org

mikeryan’s picture

I was looking to do this independently of taxonomy, I finally got back to it and wrote my first (very simple) module. Enable this module and the URI "bynodetype/{type_name}" will give you a listing of nodes of the specified type (for flexinodes, you need to use the "flexinode-1" form rather than the typename you gave it).

Comments welcome... I think this functionality could easily be added into the node module, but if a separate module is desired I can submit it.

function bynodetype_help($section) {
  switch($section) {
    case "admin/system/modules#bynodetype":
      $output = "bynodetype";
      break;
    case "admin/system/modules#description":
      $output = "Generate a list of nodes by their type";
      break;
    default:
      $output = "";
      break;
  }
  return $output;
}

function bynodetype_page() {
  $result = pager_query(
    "SELECT nid, type FROM {node} WHERE status = 1 AND type = '" . arg(1) . "' " .
      'ORDER BY created DESC', 
    variable_get('default_nodes_main', 10));

  $output = '';
  while ($node = db_fetch_object($result)) {
    $output .= node_view(node_load(array('nid' => $node->nid, 'type' => $node->type)), 1);
  }
  
  $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));

  print theme('page', $output, '');
}

function bynodetype_link($type, $node=0) {
  if ($type == "system") {
    $query = "SELECT DISTINCT type FROM {node}";
    $queryResult = db_query($query);
    while ($types = db_fetch_object($queryResult)) {
      menu("bynodetype/".$types->type, t($types->type), "bynodetype_page", 1, MENU_HIDE);
    }
  }
}
trixter’s picture

I am new to drupal and having a bit of an issue with this specific module, perhaps I missed something.

I cut and pasted the module into modules/bynodetype/bynodetype.module.

I then went to administer >> configuration >> modules and enabled the module.

I noticed that the name of the module as well as its description appeared (the description indicates that the module cut and paste was at least valid for php as there was no parse error)

I then tried to goto /bynodetype/story and it claimed that it was not found. Infact anything that I did just /bynodetype (with and without trailing slash) and anything after that resulted in a 404.

In administer >> logs >> httpd it shows a 404 for every request that I issued.

I am running drupal 4.4.2 - everything else is working so I am fairly sure that it is not my installation of drupal itself.

I even tried using mysql client to see if the sql statement was off, however that did not have any problems, and worked as expected.

I cannot think of why this module would show up in 'admin' but not be locatable anywhere else, unless perhaps the API changed a bit in 4.4.2. Any help on this would be greatly appreciated as I need this type of functionality (for book reviews, which provides no aparent means to view just the book reviews).

Thanks a lot

briandburnham’s picture

Works perfectly for me, very nice.

Brian Burnham
http://brianburnham.com

briandburnham’s picture

Have to take that back, the module generates an error on user logout. Odd. I had to deactivate it.

Brian Burnham
http://brianburnham.com

trixter’s picture

I was wondering how you got it to work? what uri did you specify?

I can live with an error on logout :)

trixter’s picture

I had apache 1.3.x installed and it failed ot work, I installed 2.0.x last night (I wanted ipv6) and now it works.. Quite odd..