So has anyone tried exporting these tokenized menu links to a feature... it doesn't work. What's necessary for features export?

Comments

dealancer’s picture

In the 7.x-1.0-alpha3 we have updated how menu_items is stored. It should integrate fine with Features. To make this possible for D6 version we must backport this functionality, see http://drupal.org/node/973882

stovak’s picture

Doing the backport now locally. Will post when complete.

stovak’s picture

StatusFileSize
new34.77 KB

This patch moves the 6.x branch to the new storage method but it still doesn't export correctly to features. No idea why.

stovak’s picture

Writing features integration with UUID. If you want to give me commit priv's to the 6.x branch, i'll commit some of this...???

stovak’s picture

StatusFileSize
new10.45 KB

Experimental Features Support

dealancer’s picture

I have just checked how features works with menu token 7.x-1.0-alpha3. It works ok if there is single menu token item in the menu. This is because of issue of Features module http://drupal.org/node/927566. If this issue will be fixed Menu Token for D7 will have this integration. BTW, this issue does not only affect on Menu Token, it will affects on Internationalized menu; Do you think this issue could be easilty fixed with unique id?

Regarding your patch, it looks ok, and I really apriciate your help. However it could not be commited cause of this reason:

We need to backport changes done in 7.x-1.0-alpha3 to D6 version of this module. Why? Cause we changed the way how menu token settings are stored. We dropped menu_token talbe and now store settings in the options field of menu_links table, it allow to gain the perfromance and to use native Drupal caching. Also this allows not to write exporting/importing functions of this settings.

So IMHO after we will update D6 version of this module, all we need is to patch features to support unique id? What do you think?

dealancer’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Issue tags: +Needs backport to D6
stovak’s picture

Unfortunately, the only way to get everything to work with UUID is to have some table where the UUID is matched up with the NodeID. You can't do a query on the UUID when it's stored in the Options field.

stovak’s picture

StatusFileSize
new44.06 KB

Ok, so this patch adds UUID to the menu_links table instead of menu_token and eliminates the menu_token table entirely. Be sure to patch this to the original D6 DEV branch and ignore/disregard any earlier patches in this issue que.

oskar_calvo’s picture

Hello stovak.

This patch works with the 6.1.1 version or we must to go back to 6-dev version?

thanks

Oskar

wizonesolutions’s picture

Status: Active » Needs work

stovak: The patch brings things a lot closer, but it doesn't seem to be there yet.

The first DB update had a bunch of errors (which I'll paste below); the second one succeeded apparently.

Output follows, but keep reading afterward:

:~/public_html/vbs/sites/all/modules$ cd menu_token/
:~/public_html/vbs/sites/all/modules/menu_token$ wget http://drupal.org/files/patch_commit_39e006eee4ae.patch
--2012-02-12 20:27:55--  http://drupal.org/files/patch_commit_39e006eee4ae.patch
Resolving drupal.org... 140.211.166.6, 140.211.166.21, 140.211.10.16
Connecting to drupal.org|140.211.166.6|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 45122 (44K) [text/plain]
Saving to: `patch_commit_39e006eee4ae.patch'

100%[============================================================================>] 45,122       208K/s   in 0.2s

2012-02-12 20:27:56 (208 KB/s) - `patch_commit_39e006eee4ae.patch' saved [45122/45122]

:~/public_html/vbs/sites/all/modules/menu_token$ patch < patch_commit_39e006eee4ae.patch
patching file menu_token.admin.inc
patching file menu_token.features.inc
patching file menu_token.inc
patching file menu_token.info
Hunk #1 succeeded at 1 with fuzz 2.
patching file menu_token.install
patching file menu_token.module
patching file menu_token_node_context.inc
patching file menu_token_node_random.inc
patching file menu_token_node_user_defined.inc
patching file menu_token_term_context.inc
patching file menu_token_term_random.inc
patching file menu_token_term_user_defined.inc
patching file menu_token_user_context.inc
patching file menu_token_user_random.inc
patching file menu_token_user_user_defined.inc
:~/public_html/vbs/sites/all/modules/menu_token$ drush updb
The following updates are pending:

 menu_token module
 6001 - description not available
 6002 - description not available


Do you wish to run all pending updates? (y/n): y
Executing menu_token_update_6001                                                                           [success]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for   [warning]
the right syntax to use near &#039;DEFAULT NULL&#039; at line 1
query: ALTER TABLE menu_token ADD `uuid`  DEFAULT NULL database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;59833d61-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 13079
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;59889953-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14009
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;598c8a08-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14010
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;59903452-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14012
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;5993212d-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14013
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;5996bea4-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14461
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;599a677a-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14463
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;599ce828-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14464
database.mysqli.inc:147
Unknown column &#039;uuid&#039; in &#039;field list&#039;                                                  [warning]
query: update menu_token set uuid=&#039;599fad20-55fb-11e1-b7f8-001bfc5286c3&#039; where mlid= 14465
database.mysqli.inc:147
ALTER TABLE {menu_token} ADD `uuid`  DEFAULT NULL                                                          [error]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]
update {menu_token} set uuid='%s' where mlid= %d                                                           [error]
update {menu_links} set options = '%s' where mlid = %d                                                     [success]

'all' cache was cleared                                                                                    [success]
Finished performing updates.                                                                               [ok]
:~/public_html/vbs/sites/all/modules/menu_token$ drush updb
The following updates are pending:

 menu_token module
 6002 - description not available


Do you wish to run all pending updates? (y/n): y
Executing menu_token_update_6002                                                                           [success]
ALTER TABLE {menu_links} ADD `uuid` VARCHAR(64) DEFAULT NULL                                               [success]
add field uuid to menu_links                                                                               [success]
drop table if exists menu_token                                                                            [success]

'all' cache was cleared                                                                                    [success]
Finished performing updates.                                                                               [ok]

The actual integration is also flawed. I have 8 or 10 menu_token-using menu items to featurize, but only 5 show up. Of the ones that show up, 3 of them don't use menu_token and the other two say they are just pointing to (at least in the Features output). A completely unrelated menu item appears in the menu_token component type that's appeared after applying the patch. Hope this test helps and contains sufficient detail.

batje’s picture

StatusFileSize
new4.84 KB

Am just using this module for a day, and took a fresh look. I found a completely new way to make this work. I might have overlooked something, but here is my approach.

Currently, menu_token stores the < front > variable in the path of every menu item. This is pretty convenient, as upon save of the menu item, Drupal checks if you have access to the path. There are very few websites where you dont have access to < front >. Upon rendering of the menuitem, menu_token replaces < front > with the calculated path based on the user_menu path tokens. This is a nice trick. However, the features menu export gives every menu a unique ID based on the name of the menu and the path. So if you have 2 menu_token enabled menuitems in 1 menu, the second one is not exported.

So, here is what i did:

  • Instead of < front > we store menutoken/[ a generated uuid] in the path of the menuitem
  • A hook_menu allows access to menutoken/%
  • In the menu item edit form, we hide the generated uuid, so its not regenerated on every save.
  • For parents, we check whether features is calling us or not. If features is calling us, we do not replace the path variable. This makes sure that the parent path is 'menutoken/[ a generated uuid] and not the generated path.

This works for me so far. Without changing features. But its pretty funky, so feedback is welcome.

I will need to test this with the menu_per_role module later.

(fixed some html formatting)

oskar_calvo’s picture

Status: Needs work » Needs review

The patch need to be review?

kim.le’s picture

I'm confused. Are these patches for Drupal 6 or 7? I'm using 7.x-1.0-beta and the menu links for features export don't appear when I check the use tokens box in for the menu link.

batje’s picture

#12 is for Drupal 7.

socialnicheguru’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta1

#12 does not apply cleanly to beta1

develcuy’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Priority: Normal » Critical

Working on patch at #12

develcuy’s picture

StatusFileSize
new5.74 KB

Patch re-rolled and pushed to 7.x-1289302 branch. Also, added an update hook that fixes current menu items that are using tokens.

Patch attached for your review. Let's make it RTBC!

develcuy’s picture

Status: Needs review » Needs work
develcuy’s picture

Status: Needs work » Reviewed & tested by the community

Issue #1896834: CTools Export Bonus integration confirms that the patch works. To be committed pretty soon.

lnunesbr’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new5.74 KB

Patch created in Drupal Camp Cartagena.

Please, needs work.

develcuy’s picture

Component: Miscellaneous » Code
Status: Needs work » Fixed

Patch committed and new release published!

a.ross’s picture

a.ross’s picture

Status: Fixed » Needs work
a.ross’s picture

I think instead of doing debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), you can just do debug_backtrace(), as all that this code uses is the function name... if you want to save memory then check first if the constant is set.

Besides that, this whole function seems to be a gruesome hack, but I don't know how necessary it is.

a.ross’s picture

a.ross’s picture

Status: Needs work » Fixed

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