[development] hook_menu vs path alias Drupal 7
devendra.in at gmail.com
Thu Feb 17 16:11:52 UTC 2011
It was still not catching the "node/%nid".
I did a quick fix as written .htaccess rewrite to redirect user from
/article/hello to /mymodule/article/hello.
RewriteRule ^article/hello$ /mymodule/article/hello [L]
My updated hook_menu
$items['mymodule/article/hello'] = array(
'title' => 'Hello World',
'description' => 'Hello world',
'page callback' => 'my_custom_function',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
I am happy now :)
On Thu, Feb 17, 2011 at 8:08 PM, nan wich <nan_wich at bellsouth.net> wrote:
> I haven't looked at that code in D7 yet, but based on D6, I am going to
> guess that it hasn't changed. The URL alias is resolved to the underlying
> "node/1234" before the menu is looked at. Since the menu specifies
> "article/hello," it does NOT match "node/1234" and therefore executes the
> standard "node/%nid" path instead. If you change the menu path to
> "node/1234," I bet it will do what you want.
> Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L.
> King, Jr.
> *From:* Deva <devendra.in at gmail.com>
> *To:* development at drupal.org
> *Sent:* Thu, February 17, 2011 8:41:21 AM
> *Subject:* [development] hook_menu vs path alias Drupal 7
> Hi All,
> I am developing a site in Drupal 7. I have a node with alias /article/hello
> I also have a hook_menu with "/article/hello" path registered in my
> When i access the path in browser http://localhost/article/hello it shows
> the node instead of calling "my_custom_function".
> $items['article/hello'] = array(
> 'title' => 'Hello World',
> 'description' => 'Hello world',
> 'page callback' => 'my_custom_function',
> 'access arguments' => array('access content'),
> 'type' => MENU_CALLBACK,
> I want 'my_custom_function' to get called.
> Appreciate your help.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the development