Aliasing node/1234
to blogs
doesn't mean you can control the rest of the menu router item.
For an example, if your unaliased node path is "node/1234" , you "own" the rest of the arguments.
i.e You can access 567
from node/1234/567
from PHP like this:
<?php print arg(2); ?>
If you want to "own" /blogs
URL part, you have to define it using hook_menu. As you have already touched php, I think the best way would be making the module.
You can however use Views or Panels modules for that.
<?php
function MYMODULE_menu() {
$items = array();
$items['blogs'] = array(
'title' => 'Main Blogs page',
'page callback' => 'MYMODULE_page',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
);
$items['blogs/%'] = array(
'page callback' => 'MYMODULE_blog_view',
'page arguments' => array(1),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function MYMODULE_blog_view($blog_id){
// $node = node_load($blog_id);
// return print_r($node, TRUE);
}
?>
Now, in MYMODULE_blog_view function, you can get the arguments from arg(1) as well. You can also make it in a single page callback by combining both menu router items but I'd recommend separate router items.
Update( Aug 8 ) :
The reason why I used node_load($blog_id) and other commented junk there is assuming you needed parts from the node (e.g: You want make show a View with the node ID argument, or something similar that needs specific data from the node).
But never allow users to view a node loaded from node_load() because it's like god giving whatever the user asks for.
For nodes, let me explain a little gimmic. Put this in the callback function.
$node = node_load($blog_id);
if ($node && $node->type == 'blog'){
$_GET['q'] = 'node/' . $node->nid;
return menu_execute_active_handler('node/' . $node->nid, FALSE);
}
drupal_not_found(); // important!
This will load the node ID from the blog ID (which is from the URL), check if it's in 'blog' type and sets the menu handler to the relevant node ID path.
Now, when you access blog/123 , you will see content of node/123 if it's a blog node. But it's not a redirection. It will not work as fully aliased URL but is helpful sometimes.
Alternately you can check if theuser has access to the node from node_access().