I can't list only stories or only pages.
I tried using "page" or "story" as a path in the menus but it didn't work.
I think there is an easy way to list all types of content in the same way you can list blog entries by typing "blog" in the path field for the menu item. But i can't find these default paths. Any help will be appreciated!

Comments

budda’s picture

I think you need to get hold of the excellent Views module!

--
Ixis (UK) providing Drupal consultancy and Drupal theme design.

rszrama’s picture

It does work for blog, but that's part of the blog module (see blog_menu for the path setting and blog_page for its callback function) whereas story.module and page.module have no such functions.

What you can do is a custom page that lists them by creating a page, setting its input type to PHP and using a variation of the following code:


  $query = "SELECT nid, title FROM node WHERE type='page' ORDER BY created DESC LIMIT 0, 5";
  $result = db_query($query);
  while ($page = db_fetch_object($result)) {
    echo $page->title . "<br>\n";
  }

This should list the last 5 created pages for you. You can fiddle with the 'LIMIT 0, 5' portion to increase how many are displayed, or take it out to show them all. Change type 'page' to 'story' for stories. Also, you can change what output is displayed.

Using the functions node_load and node_view you can list teasers instead of the title.


  while (....) {
    $node = node_load($page->nid);
    $output .= node_view($node, true);
  }
  echo $output;

That should work.. may need some tweaking.

heine’s picture

The first snippet is insecure:

It bypasses node access restrictions
It doesn't check user supplied data on output.

See http://drupal.org/node/62304

--
The Manual | Troubleshooting FAQ | Tips for posting | Make Backups! | Consider creating a Test site.

rszrama’s picture

My bust, I just copied that from code I use on a site where I don't bother w/ restrictions since I'm the admin. = P

johnhanley’s picture

While Heine is fundamentally correct that your snippet doesn't conform to Drupal secure code standards, in this case the risk is minimal because no user-supplied data is being passed.

amnon’s picture

A simple solution is to install the tiny node_type_filter module.

Then you can append ?type=story, for example, to various paths, to filter the content.

Mike_Waters’s picture

FYI There is an option for this (Filter by node type) in (at least) the current version of Views for Drupal 5.x (I have Views version 5.x-1.6).