Smart Node Links

Component ID

1875158

Component name

Smart Node Links

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

723

Component created

Component changed

Component body

This simple module provides a page path to show the latest node in full page view in the same manner as if one were to visit, say, node/123, where 123 is the very latest node created. It queries the db for the max entity_id and redirects to it, automatically presented by its url alias.

How to use

This module adds a new "node path" suffix /latest to display the latest node in full node page view. Additionally, append the content/entity type to get the latest of a certain type. Ex:

  • node/latest
  • node/latest/article
  • node/latest/any-content-type-machine-name

Download and enable the module.

Why this module

The goal of this module is not to reinvent the wheel but to make things simple for new Drupalists. Also, I found no straightforward way of achieving the same: I had tried setting Site Front Page to "node" and leaving the count 1, but the node shown was a Teaser view-- even when I changed Teaser > Body to Default (untrimmed). Have tried a Views approach, but even this "Full Content" view wouldn't invoke all the node hooks of other modules. In the end, what I really needed was a complete and honest Full Node Page view without hardcoding a specific nid/entity_id in the path, and this module was born.

Note: Specifically as a Front Page solution, it should be possible to provide a PHP function as default landing for your site, but why?

Use Case

Set Drupal Front Page to Latest Node in Full Page View

Set site front page to "node/latest/article"
This queries the site db for the latest (by entity_id) entity of type "article" and displays it for the site home page

Share "Latest News" in Emailed links

Share the path to your site as http :// example.com/node/latest/photo (assuming you have a "photo" content type).

Future

With the whole Mayan 2012.12.21 behind us, we can talk about the future of this module: I would like to see:

  • Just display the node instead of invoking drupal_goto (which I believe does a clientside redirect)
  • Complete user_access. This module currently assumes Anonymous has Can See Content and that the requested "latest" content should be able to be seen.