I am working on a newspaper site and I have gotten every thing to work but the menu has been a challenge. I was reading thru this article http://drupal.org/nyobserver#comment-722379 and they explain their approach as...

Scheduled publishing. The Home and Channel pages use a simple menu callback function that selects the correct Edition node for that page by choosing the one with the newest Effective Date in the past. It then just calls return node_view($nid). Simple. 

While I get node_view($nid) I don't understand how to write that sort of lookup/iterate into a menu hook. Has anyone done something similar? Seen examples of it?

Comments

ryanmills’s picture

bumping with hope.

-RM

nevets’s picture

First off you may want to check out the E-Publish module which may make things simplier.

If you still want to write code this may help. Lets give our module the name 'mymodule' and a menu hook that at least has

function org_menu($may_cache) {
  $items = array();
	
  if ($may_cache) {
     $items[] = array(
      'path' => 'home',
      'title' => t('Home'),
      'description' => t('Home menu entry.'),
      'callback' => 'mymodule_current_edition',
      'callback arguments' => array('home'),
      'access' => TRUE,
      'type' => MENU_NORMAL_ITEM
    );
     $items[] = array(
      'path' => 'channel',
      'title' => t('Channel'),
      'description' => t('Channel menu entry.'),
      'callback' => 'mymodule_current_edition',
      'callback arguments' => array('channel'),
      'access' => TRUE,
      'type' => MENU_NORMAL_ITEM
    );
  }

  return $items;
}

We now need a callback function called 'mymodule_current_edition' that takes one argument that determines what we are looking for.

function mymodule_current_edition($what) {
  // At this point you need to construct a query that will get the approriate node
  // Since nodes don't have a default effective date the query depends on how/where that field is stored.
}