I am looking for an elegant (as much as possible) solution to build a specific page in a Drupal website.
So, I started with :
function hook_menu() {
$items = array();
$items['module/articles'] = array(
'title' => 'List of articles',
'page callback' => 'show_article_list',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
$items['module/articles/%'] = array(
'title' => '',
'page callback' => 'show_article_page',
'page arguments' => array(2),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
The first item return the list of my articles, and, the second build a page for the article % (where % is an id to make it simple).
The point is, I use a webservice to get the list, and each page. So the page callback makes a call to my webservice (http://api/articles for instance) and build the page according to the result.
It works. But, if I want to set the title of each % page, I have to use a title callback, which is another function. And, I don't want to make another call to my webservice. To make it clear : http://api/articles/id, returns the title and the content in one result. So using two methods makes me calling this url twice : one for the title, and another one for the content.
Is there a better approch to solve this problem ?
Many thanks in advance,