The Menu Breadcrumb module combined with this one would allow for very easy breadcrumb creation. As a side note, creating the menu item but having it in a disabled state would be quite nice. Adding an action for updating the menu would be handy as well; for use with views bulk operations.

CommentFileSizeAuthor
#58 menu_token.tar_.gz1.38 KBygerasimov
#6 menu_token.tar_.gz8.04 KBDevElCuy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Flying Drupalist’s picture

Subscribe

DevElCuy’s picture

Awesome ideas!

What about a code sprint? Drupal Perú is going to have the next meet on February 21, is that day ok? more suggestions?

Blessings!

DevElCuy’s picture

I have done a first attempt to migrate, seems very tricky and hard...
Problem is that in D5, $_menu is global, but in D6, menu links and routes work separated and are menu tree is saved to static variables...
Right now, I'm looking for some way to override D6 core functions.

steveadamo’s picture

i'm sure this is grossly oversimplified, but i ran the D5 version through coder, and worked out all the "kinks" it found... it succesfully loaded in D6...

problem is, i never used the version in D5, so im not sure where to look to see if it installed correctly... ;)

installing a new D5 site to test...

DevElCuy’s picture

Here is what I have at the moment. All about interface looks the same as in D5, but token replacements are not working yet.

Blessings!

DevElCuy’s picture

Status: Active » Needs work
FileSize
8.04 KB
jogebau’s picture

Im on drupal 6 and really intereseted in this. please keep going...

ldbl’s picture

I test it seems you bypass internal checking if url is valid.
Some idea how to print this callbacks on menu_alter. I can see them only when I clear the cache.
I want to play around.

DevElCuy’s picture

The problem is that new menu system stores general menu definition in 3 static variables, they are for internal usage of functions only.
What I'm thinking now is to provide menu_blocks or hook in themes.

Blessings!

peddecke’s picture

subscribe

preventingchaos’s picture

I'm very interested in this, too.

subscribing

scotthenning’s picture

Agreed. This would be really helpful...

DevElCuy’s picture

I'm happy to know you are interested on this module. But I would like to have your feedback into an sprint.
I have created a doodle event so you can choose the dates you have time into the next week, I'll be available via skype and IRC.
http://doodle.com/wbc4dmhhsvnybb4u

Hope you can participate.

Blessings!

mikeytown2’s picture

heads up, #322669: Hiding option for automenu implements making the new menu item being disabled. Could probably grab some code from that module... actually if Auto Menu had token support, that would be quite amazing. Found that module today with this search
http://drupal.org/project/modules?filters=drupal_core:87&text=Menu - about 35 legitimate menu modules for D6

restyler’s picture

any news? subscribing

George2’s picture

i have a feeling this may well be impossible in 6

gunzip’s picture

subscribe

dropchew’s picture

subscribe

superdorx’s picture

Is this ready for testing on 6?

design.er’s picture

awesome! I also have to subscribe. It will save a lot of peoples life. :)

mgladding’s picture

Subscribing!

DevElCuy’s picture

Awesome! this is what I call "community" presure, If some of you want to put "hands on" for this module, please join the codesprint at: http://groups.drupal.org/node/21813
I will start working on this module at 6pm GMT -5 this Saturday 16

Blessings!

Heilong’s picture

Subscribing...

mitchell’s picture

subscribe

Heilong’s picture

I took a look at the module " Me alias " , which contributed a bit to what I wanted : http://drupal.org/project/me , could be useful.

DevElCuy’s picture

D6 menu system does not allow rewrite as was possible in D5. Which is the solution? to provide a "Menu Token" version for every available menu block and add theme variables for primary and secondary links.

Another challenge is to manage the tokenized menu entries, it needs a custom interface because core will not list invalid menu links.

CONCLUSION
Menu Token module will not be integrated with D6 core.

So ...

/**
 * Implementation of hook_block().
 * 
 * Based on menu_block() at modules/menu.module
 */
function menu_token_block($op = 'list', $delta = 0) {
  $menus = menu_get_menus();
  // The Navigation menu is handled by the user module.
  unset($menus['navigation']);
  switch ($op) {
    case 'list':
      $blocks = array();
      foreach ($menus as $name => $title) {
        // Default "Navigation" block is handled by user.module.
        $blocks[$name]['info'] = t('Menu Token') .': '. check_plain($title);
        // Menu blocks can't be cached because each menu item can have
        // a custom access callback. menu.inc manages its own caching.
        $blocks[$name]['cache'] = BLOCK_NO_CACHE;
      }
      return $blocks;
    case 'view':
      switch ($delta) {
        case 0:
          $data['subject'] = check_plain($menus[$delta]);
          $data['content'] = menu_token_tree($delta);
          break;
      }
      return $data;
  }
}

Notice a call to function menu_token_tree(), which is a also a "rewritten" function for menu_token, and just redirects to menu_token_tree_output() another rewrite, as seen below


/**
 * Render a menu tree based on the current path.
 *
 * The tree is expanded based on the current path and dynamic paths are also
 * changed according to the defined to_arg functions (for example the 'My account'
 * link is changed from user/% to a link with the current user's uid).
 *
 * @param $menu_name
 *   The name of the menu.
 * @return
 *   The rendered HTML of that menu on the current page.
 */
function menu_token_tree($menu_name = 'navigation') {
  static $menu_output = array();

  if (!isset($menu_output[$menu_name])) {
    $tree = menu_tree_page_data($menu_name);
    $menu_output[$menu_name] = menu_token_tree_output($tree);
  }
  return $menu_output[$menu_name];
}

/**
 * Returns a rendered menu tree.
 *
 * @param $tree
 *   A data structure representing the tree as returned from menu_tree_data.
 * @return
 *   The rendered HTML of that data structure.
 */
function menu_token_tree_output($tree) {
  $output = '';
  $items = array();

  // Pull out just the menu items we are going to render so that we
  // get an accurate count for the first/last classes.
  foreach ($tree as $data) {
    if (!$data['link']['hidden']) {
      $items[] = $data;
    }
  }

  $num_items = count($items);
  foreach ($items as $i => $data) {
    $extra_class = NULL;
    if ($i == 0) {
      $extra_class = 'first';
    }
    if ($i == $num_items - 1) {
      $extra_class = 'last';
    }
    $link = theme('menu_item_link', $data['link']);
    if ($data['below']) {
      $output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
    }
    else {
      $output .= theme('menu_item', $link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
    }
  }
  return $output ? theme('menu_tree', $output) : '';
}

ATM, function menu_token_tree_output() is not ready, it should rewrite paths with tokens.

tomhung’s picture

Why cant this module just be an extension of the 'me' alias module.

G

DevElCuy’s picture

@tomhung, menu_token.module is intended to bring the power of token to menu paths. It is not just about user->uid, but about current loaded node, its taxonomies, cck fields, etc... So you can build "intelligent" menu items which will appear according to the context.

jstoller’s picture

Subscribe.

May the force be with you!

redijedi’s picture

subscribing

design.er’s picture

I tested the module from #6.
I tried to create a link to the account-edit page with user/[user-id]/edit and activated the checkbox "user tokens".
When click on submit I'm landing on the page where all the links of a category (i.e. primary links) are but it seems that this link was not saved. I tried it several times, always with the same result.

Please let me know if you need more information.

Regards,
Stefan

shawnspqr’s picture

Subscribing

luxx’s picture

Subscribing

TC44’s picture

This would be very useful. Thanks for the efforts.

Aerodynamo’s picture

I agree, this would be great! I would love a D6 port.

George2’s picture

again, when i looked at making a patch, because of the HUGE differences between the menu system of 5 and 6, i believed, and still do, a port will be impossible.

jweberg’s picture

sub +1

jweberg’s picture

I think incorporating token replacement for the menu link title would be great. I'm looking for a solution for this right away. I've scoured the forums and didn't find anything. Does anyone have a solution for this?

mani.atico’s picture

Although it might be impossible I have to subscribe.

I haven't checked the proposal throughfully, but of what I know about Drupal's menu system and of what I have read in this issue I think that maybe the only pausible solution is creating a patch to add a hook to menu_link_load function.

luxx’s picture

jweberg: mod rewrite for apache I think

himagarwal’s picture

subscribing

drupov’s picture

subscribing

himagarwal’s picture

Is there possibilities that this module will be ported to drupal6, since it has already been more than 3 months that we have heard anything from develCuy.

jstoller’s picture

And if it's not going to make it to D6, have the changes in D7 improved the future outlook for this module any?

himagarwal’s picture

as suggested by #25, the "Me alias" http://drupal.org/project/me did the trick for now. But a D6 port somehow with hack would be fantastic!

pimousse98’s picture

subscribe. This feature would be great, either in D6 or 7.

DevElCuy’s picture

Priority: Normal » Critical

Current implementation of D6 makes it really hard, as said before, would need to create a new table for storing tokenized links. Problem is that we'll have to forget about integration with other modules. So, this is a menu sub-system, running in top of core's menu system.

I don't like this scenario but is all we can do without hacking the core(top rule). Now, if there is real interest, please consider sponsoring the project, now that you know how far we can go, which is not that bad :)

jrabeemer’s picture

Wow, the premise of this module is awesome to think about. Yes, me module fits one specific need, but this is a generalized solution that we all need.

+1 for D6 port. +2 for D7 :-)

mrfelton’s picture

nothing to add... just subscribing to the thread.

benone’s picture

subscr

GeekyLass’s picture

Subscribing.
If I was a coder I would help but ... unfortunately my strength does not lie in this area.

gilcpd’s picture

subscribing

Kars-T’s picture

Hi

what is the status of this module and issue?

Couldn't we rewrite the links by using
http://api.drupal.org/api/function/theme_menu_item_link/6
and rewrite any tokens in the URL in the theming layer?

This would be quiet easy and we could use the current global context.

k3vin’s picture

+

Summit’s picture

Subscribing,
How about a D6 version please?
greetings, Martijn

mitchell’s picture

Views build menu may be useful to those watching this issue.

not_Dries_Buytaert’s picture

+1 for a D6 solution

ygerasimov’s picture

Status: Needs work » Needs review
FileSize
1.38 KB

Please review Drupal 6 version for this module. Please test and let me know your comments.

@develCuy Can I request maintainership for this module?

DevElCuy’s picture

Thanks for the new version suggestion, I have given you commit access, will evaluate your progress to give you full maintainer permissions.

drupov’s picture

Works!

@ygerasimov: Thanks for the great job!

ygerasimov’s picture

Status: Needs review » Fixed

Comitted to DRUPAL-6--1 branch.

DevElCuy’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

With the release of D7 beta, the D5 branch of this module is now archived.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.