I've developed a menu service module. Currently it only supports single level menus. Let me know i you want to integrate it or maybe just have a look.

Thanks for a VERY nice module!

Best,
/Johs.

CommentFileSizeAuthor
#11 menu_service.zip956 bytesAnonymous (not verified)
#4 menu_service_1.x.dev_.patch7.49 KBg10
#2 menu_service.txt1.28 KBjohsw

Comments

snelson’s picture

I'd like to see your code. I think this would be a good addition to Services.

Thanks,
Scott

johsw’s picture

StatusFileSize
new1.28 KB

Hi Scott

Here's the service. It's been a while since I looked at it. It's probably buggy and hackish :-)

Best
/J.

Anonymous’s picture

Hi,

I have had a look at your menu service add on to the menu module. It works great but what I don't like about it is that it directly asks the database for the menu items without going through drupal's core menu module.
I was wondering if you have made any progress on this service or if anyone knows how drupal's core menu module retrieves the menus. I would like to know this because I would like to be able to access the various core navigation menus according to the role I am using. For example, if I am an anonymous user the menu service should only show me the available menu items for that user. I have done alot of research yet, due to my amateur PHP knowledge, I don't quite get how the core menu module works.

Thanks

g10’s picture

Status: Active » Needs work
StatusFileSize
new7.49 KB

Hi,

got here a menu service which I have been using (from before AMFPHP 1.9b2 was supported, therefore some parts are not as clean)
this one supports multi-level
also it is a bit customised to my needs I have for my flash framework (eg. it loads some custom fields from a node, which should be deleted), + returns the languages, server time, …
also the pathalias is returned, which is the only part that does straight calls to the database

I planned to rework this one allready a couple of months, so it could be contributed, but I didnt find a chance to do so… therefore consider this as a base for your needs (delete the unwanted stuff)

I'll try to adjust this to a generalized version asap, and get it more inline with the Drupal coding conventions (stdClass objects instead of named arrays, no custom fields loading but fields filtering as node.load does etc)

hope this helps someone out for the time being,
g10

Anonymous’s picture

Thnks m8! Will check it out tonight

marcingy’s picture

Assigned: Unassigned » marcingy
marcingy’s picture

Just had quick look at the path and the menu service shouldn't be responsible for handling i8n. Also it should drupal functions to build the menu structure.

marcingy’s picture

Assigned: marcingy » Unassigned
Anonymous’s picture

Any updates to the menu service?

Hi Marcingy... have you created a menu service by any chance?

marcingy’s picture

No it is marked to me simply for purposes of review and consideration as to whether or not is was going to be included as part of the attempt to get webservices into core. The code here isn't of the required standard. We still want to look to get the menu service in as part of D7, but we will be starting a fresh. A version will not be developed by myself for d5.

Anonymous’s picture

StatusFileSize
new956 bytes

Well for D5 I have created a very simple menu service which gets all the menu data... I then use AS to filter the results and create an internal XML to be used in conjunction with Jumpeye's menu tree components allowing me to selectively place the menu items where they are needed. The module file uses the menu_get_menu so it gets the data via the menu module. I've posted it here. Tell me whether you think it is a correct implementation.

marcingy’s picture

Assigned: Unassigned » marcingy

I'll review and test this later but I have a had a quick look at the code and I like the idea and it certainly gives a starting point.

Anonymous’s picture

Well I have found that it actually works quite well because you get all of the menu data including all menus and all info. However for filtering with AS3 it can be quite difficult because, if by any chance a particular "mid" number is missing (mid being the number that is given at the top of each menu item with its list of data (those that are negative eg. -22 are generally admin menus) then the "for" loop in AS3 gives a runtime error because it cannot continue.

Here is a sample from the results of the call method... these results are the ones I have identified as primary links because they are of type 118 (which can be different for other drupal sites hmmm.. how to work around this one):

[113] => Array
(
[path] => node/30
[title] => Solutions
[description] => Solutions
[pid] => 2
[weight] => 0
[type] => 118
[children] => Array
(
[0] => 115
[1] => 117
)

)

[114] => Array
(
[path] => node/31
[title] => Products
[description] => Products
[pid] => 2
[weight] => 1
[type] => 118
[children] => Array
(
[0] => 116
)
/// NOTICE THE FACT THAT [115] is missing
)

[116] => Array
(
[path] => node/32
[title] => Resource Management
[description] => Benefits of NEXThink's IT Behioural Intelligence™ Technology
[pid] => 113
[weight] => 0
[type] => 118
)

[117] => Array
(
[path] => node/33
[title] => Architecture
[description] => N/A
[pid] => 114
[weight] => 0
[type] => 118
)

[118] => Array
(
[path] => node/34
[title] => Change Management
[description] => Managing Change
[pid] => 113
[weight] => 1
[type] => 118
)

[119] => Array
(
[path] => node/35
[title] => Services
[description] => Services
[pid] => 2
[weight] => 2
[type] => 118
)

[120] => Array
(
[path] => node/36
[title] => Research
[description] => Passion for Innovation
[pid] => 2
[weight] => 3
[type] => 118
)

[121] => Array
(
[path] => node/37
[title] => Partner
[description] => Partner Ecosystem
[pid] => 2
[weight] => 4
[type] => 118
)

[122] => Array
(
[path] => node/38
[title] => Company
[description] => More about us
[pid] => 2
[weight] => 5
[type] => 118
)

and here is the function I use to filter some of the data (ps. it's far from complete and it gives of an xml which can be assigned to Jumpeye components):


private function cbMenu(result:Object):void {
     var componentV3:XML=<component name="Drop Down Tree Menu v3"></component>;;
     var datas:XML=<data></data>;;
     var subdatas:XML=<main></main>;;
     componentV3.appendChild(datas);
     datas.appendChild(subdatas);
     for (var i=113; i < result.length; i++) {
          if (result[i].type == 118) {
               trace("_______________________________________________");
               trace("titl:   " + result[i].title);
               trace("wght:   " + result[i].weight);
               trace("desc:   " + result[i].description);
               trace("path:   " + result[i].path);
               trace("pid :   " + result[i].pid);
               if (result[i].pid == 2) {
                    var node1:XML=mainChild(result[i].title);
                    subdatas.appendChild(node1);
               }
               trace("_______________________________________________");
          }
     }
     trace("_______________________________________________");
     trace(componentV3);
     trace("_______________________________________________");

     if (mainMenu.child == null) {
          mainMenu.child=new JDropDownMenu();
          mainMenu.addChild(mainMenu.child);
     }

     mainMenu.setXML(componentV3);
}

private function mainChild(str):XML {
     var xml:XML=new XML("<item title='" + str + "'></item>");
     return xml;
}

The above code is a snippet from a "main.as" class which imports the necessary classes for this function to work. main.as has the necessary functions to load data from drupal too. I will post a full tutorial of how to achieve this later on

Anonymous’s picture

OK... fixed the problem of the above... once I get a decent flash menu system sorted I will post up a tutorial on how to implement the menu service with your AS3 projects. Until then... have a nice day.

brmassa’s picture

Status: Needs work » Fixed

Guys,

a patch from http://drupal.org/node/301259 was already commited.

regards,

massa

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

robin van emden’s picture

For those interested, a D7 version can be found here:

http://drupal.org/project/services_menu