<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.28.0">
</HEAD>
<BODY>
Hi Lluis<BR>
It might be worth having a look at how devel module does it in function devel_install.<BR>
It registers a new menu on install and adds menu items to the menu, reusing the core menu and block modules and hence allowing the user to modify the menu at a later date and also any other contrib modules that interact with and extend these modules.<BR>
This is how the devel menu block is created.<BR>
Lee<BR>
<BR>
On Wed, 2010-09-29 at 13:20 +0200, Lluís Forns wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
One minor correction:
$menu = array(
'path1' => 'title1',
'path2' => 'title2',
);
foreach($menu AS $key => $value) {
$item=menu_get_item($key);
if ($item['access'] !== TRUE) {
unset($menu[$key]);
}
else {
$menu[$key] = l($value, $key);
}
}
$block['content'] = theme_item_list($menu);
return $block;
--
*Les normes hi són perquè hi pensis abans de saltar-te-les
*La vida és com una taronja, què esperes a exprimir-la?
*Si creus que l'educació és cara, prova la ignorància.
*La vida és com una moneda, la pots gastar en el que vulguis però
només una vegada.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.
2010/9/29 Lluís Forns <<A HREF="mailto:enboig@gmail.com">enboig@gmail.com</A>>:
> After some research, I think the easiest way is to create a block in
> my module and the in $delta=view put:
> $menu = array(
> 'path1' => 'title1',
> 'path2' => 'title2',
> );
> foreach($menu AS $key => $value) {
> if (!menu_get_item($key)) {
> unset($menu[$key]);
> }
> else {
> $menu[$key] = l($value, $key);
> }
> }
> $block['content'] = theme_item_list($menu);
> return $block;
>
>
> It don't need and extra module and as it don't have any configuration,
> it is easier to push changes from development site to production site.
>
> --
> *Les normes hi són perquè hi pensis abans de saltar-te-les
> *La vida és com una taronja, què esperes a exprimir-la?
> *Si creus que l'educació és cara, prova la ignorància.
> *La vida és com una moneda, la pots gastar en el que vulguis però
> només una vegada.
> *Abans d'imprimir aquest missatge, pensa en el medi ambient.
>
>
>
> 2010/9/29 Nikola Kotur <<A HREF="mailto:kotnick@gmail.com">kotnick@gmail.com</A>>:
>> On Wed, 2010-09-29 at 09:58 +0200, Lluís Forns wrote:
>>
>> In my module I want to create a block with menu links. Which is the
>> correct way to do it so permissions are checked?
>>
>> Why don't you use Menu Block module (<A HREF="http://drupal.org/project/menu_block">http://drupal.org/project/menu_block</A> )?
>> Or, you could see in it how it should be properly done.
>>
>>
>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>