Creating a page from a List of Nodes

You'll often want to make a page not from a single node, but from a list of several nodes. I haven't yet come across a technical Drupal word for such a page, so I'll call it a 'node-list page'.

Node-list pages and the Drupal Way

There are several ways to make a node-list page. What's important is to first understand the way you don't do this in Drupal. You don't create an empty "container" page – say, a blank page with the path product_catalog – and then say, "I want this node and this node and this node to appear on that page". That's a common misunderstanding among new Drupal admins, though it's a very understandable one: It does seem a logical way to do things, and some content management systems do have you do things just that way.

Drupal has you do something else: It has you specify the criteria for selecting multiple nodes – for example, "all nodes tagged with the Term 'product'", or "all Blog entries posted in 2007". That's all you do. Drupal then creates a list from those selected nodes and creates a page around that list.

That's at least the general rule (the front page provides a special case, discussed below). At first glance, it may seem limiting: You can't just pick this node and this node and this node and tell them to appear on a certain page; you have to give Drupal some criteria for picking those nodes, which means you have to find – or create – something in common among those nodes (like node type, Terms, posting dates, etc.).

But it's more powerful than it is limiting. When you want a catalog page to list all 100 of your products, the thing that you can do – give Drupal a single instruction to build the page product_catalog from all nodes tagged with the Term 'product' – is a lot better than the thing that you can't do – laboriously edit 100 product nodes to tell each one that you want it to appear on the product_catalog page. It's strong mojo.

Ways to make a node-list page

Creating a node-list page based on taxonomy

This is the business of having Drupal call up all nodes tagged with a Term (like 'products'), and has already been covered in multiple steps. Here they are together:

1. Get the path(s) for the desired Term(s). See Content Paths and URLs.

2. Create the link to the Term(s). See Creating Links.

3. Place the link in a menu or wherever desired. See Working with Menus: Administration Form.

As an example, you might create a node-list page by creating a menu item that links to a path like taxonomy/term/49+58. That's a perfect example of creating a page that doesn't even exist as a 'page' in the way that other web platforms might see a page. Rather, you created a link with instructions to Drupal to make a page, not a link to a page per se.

Creating a node-list page of Blog entries

Drupal has a built-in easy way to list all blog postings, under the assumption that this is something you're likely to want to do. As above, the path is key; place that path as a link in a menu item, and you've got an easy way to create a page which will list any and all published Blog entries.

Path for all published Blog entries:

<your site domain>/blog

Path for all published Blog entries by a specific user (for sites with multiple users):

<your site domain>/blog/<user name>

Creating a node-list page based on other criteria

You can build a list of nodes based on node type, date, author, and countless other factors, or some complex combination of those, allowing really useful tricks. The secret weapon here is an add-on function called Views.

Building a View is a rich-enough topic that it'll get its own page here shortly.

Creating a node-list page on your front page

Many sites use the front page to list a number of nodes, or short excerpts from a number of nodes. This is easy to do in Drupal, which treats the front page in a special way. You can make your front page a node-list page in one of two ways:

1. Take any path from the above – a path to a taxonomy Term, to a blog, or to a View – and set that path as the default front page.

2. Set no special path as the default front page. Rather, on the Edit form for all nodes you'd like to appear on the front page, check 'Promoted to front page' under 'Publishing options'. (This is an exception to the Drupal Way of "building" a node-list page via instructions; it's a method, like some other content management systems use, of telling specific nodes to appear on a specified page. Drupal offers this option only for the front page!)

For details on both of the above, see Setting the Front Page.

Comments

Unknown Drupaloid's picture

good one post

hyuntal's picture

.... yeahç! it doesn't work for me...

qianafree's picture

The links were of great help in getting an easy way to create a page which will list any and all published blog entries. Thanks.

Name: lashondaread
Comapny: expresso pas cher

Muhabbet's picture

Thank you a lot about very beneficial to my work was very useful thank you

Parbrize auto's picture

I found useful info here, thanks.

differentspin's picture

I couldn't find the answer to this this question anywhere else!

Add new comment