hello everybody
I want to add a link in the primary links to my own module
<?php
// $Id$
/**
* @file
* Module for shopping basket
*/
function StevenContact_menu(){
$items['admin/settings/StevenContactAdmin'] = array(
...
);
$items['admin/settings/StevenContactClient'] = array(
'title' => 'Steven contact form',
'page callback' => 'kensoContact_client_form',
'access arguments' => array('Access Admin KensoContact'),
'description' => t('The contact form for clients'),
'access callback' => 'user_access',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
...
the second item has to be linked in primary links
can somebody help me?
PS: I know you can do this in menus-> primary links -> add item, but i need to do this in code...
Comments
You could override it in your
You could override it in your theme, here we call the theme 'yourtheme'
It is quite possible that this function already exists in your template.php file, so all you have do so is add that line inserting the link (btw it might be themed differently than the default bulleted list above, but im sure youll figure that out)
This is probably not the cleanest way, but im not sure how do do it inside a module.
(Edit: apologies: this is a drupal 5 way of doing things, ill investigate further for D6)
Ah, here we go There is a way
Ah, here we go
There is a way to do it inside a module after all
http://api.drupal.org/api/function/menu_link_save/6
There are other keys you can add, but that's the bones of what you're looking for, I think.
thanx a lot, but... it
thanx a lot, but... it doesn't work
Do i have to set this code in .install or . module?
When i'm gonna look in my database, there is a new record, so it is submitted... but my link doesn't appear under primary links...
also when i'm leave menu_name away the link doesn't appear... what am I doing wrong
function stevenContact_install(){
$link = array();
$link['link_title'] = 'Contact';
$link['link_path'] = 'admin/settings/stevenContactClient';
$link['menu_name'] = 'primary_links';
$link['mlid '] = NULL;
menu_link_save($link);
drupal_install_schema('stevenContact');
}
It needs to be set in
It needs to be set in .module. Also clearing the menu cache afterwards is probably a good idea
thanks a lot,it works
thanks a lot,it works
on what hook it the .module ?
Can I use in the hook_menu? I do not want to fire it on every page load...
..:| Tomer Fish |:..
fatFish - Lean Mean Coding Machine
hook_enable()
I have the same question. My guess is hook_enable(), but a confirmation would be nice.
--
http://cheppers.com
it works
I tried hook_enable() and it works.
Don't forget to use hook_disable() to remove the link when your module is disabled!
--
http://cheppers.com