Hi. I have created a new node call "zbnews" that derive from story node. I can insert, see, and update my node. Now I want to create a way to redirect the user to an external page if he clicks onto my link zbnews/goto/{node->nid}
I have this code:
function zbnews_menu($may_cache) { $items = array();
if ($may_cache) { $items[] = array('path' => 'node/add/zbnews', 'title' => t('Aggiungi una notizia'), 'access' => user_access('create zbnews')); $items[] = array( 'path' => 'zbnews/goto', 'title' => t('Page redirect'), 'callback' => 'zbnews_goto', 'type' => MENU_CALLBACK, 'callback arguments' => arg(2), 'access' => user_access('access zbnews')); }
return $items; }
function zbnews_goto($lid = NULL, $url = NULL) { header("Location: http://www.mysite.com"); }
But when I click,eg, <a href="?q=zbnews/goto/5">Link nr.5</a>, Drupal return me page not found.
Where is my error ?
Tnx.
On Tuesday 21 February 2006 06:35 am, michel ziobudda morelli wrote:
Hi. I have created a new node call "zbnews" that derive from story node. I can insert, see, and update my node. Now I want to create a way to redirect the user to an external page if he clicks onto my link zbnews/goto/{node->nid}
I have this code:
function zbnews_menu($may_cache) { $items = array();
if ($may_cache) { $items[] = array('path' => 'node/add/zbnews', 'title' => t('Aggiungi una notizia'), 'access' => user_access('create zbnews')); $items[] = array( 'path' => 'zbnews/goto',
See if 'path' => 'zbnews', works.
'title' => t('Page redirect'), 'callback' => 'zbnews_goto', 'type' => MENU_CALLBACK, 'callback arguments' => arg(2), 'access' => user_access('access zbnews'));}
return $items; }
function zbnews_goto($lid = NULL, $url = NULL) { header("Location: http://www.mysite.com"); }
But when I click,eg, <a href="?q=zbnews/goto/5">Link nr.5</a>, Drupal return me page not found.
Where is my error ?
Tnx.
Jason Flatt ha scritto:
See if 'path' => 'zbnews', works.
OPs. No. It does not work. And now ?
Tnx.
On Tuesday 21 February 2006 07:45 am, michel ziobudda morelli wrote:
Jason Flatt ha scritto:
See if 'path' => 'zbnews', works.
OPs. No. It does not work. And now ?
Sorry, I don't have any other ideas. In my own attempt to create a custom node type, all the URLs came up as node/$nid
Jason Flatt ha scritto:
On Tuesday 21 February 2006 07:45 am, michel ziobudda morelli wrote:
Jason Flatt ha scritto:
See if 'path' => 'zbnews', works.
OPs. No. It does not work. And now ?
Sorry, I don't have any other ideas.
Resolved:
function zbnews_menu($may_cache) { $items = array();
if ($may_cache) { $items[] = array('path' => 'node/add/zbnews', 'title' => t('Aggiungi una notizia'), 'access' => user_access('create zbnews')); }
$items[] = array( 'path' => 'zbnews/goto', 'title' => t('Page redirect'), 'callback' => 'zbnews_goto', 'type' => MENU_CALLBACK, 'callback arguments' => $node , 'access' => user_access('create zbnews'));
return $items; }
But now, I have another problem: into my zbnews_goto function I want to set a new item of $node array so that in page.tpl.php I can manage it. Tnx.