DrupalSite and menu.get

Events happening in the community are now at Drupal community events on www.drupal.org.
cmcintosh's picture

Okay. I am looking at trying to expand on the ThirdAve drupalSite class so that i can get Menus from drupal to place in my flash version of the site. Is there any documentation on doing this?

So far what I have:
/*
getMenu: Get Drupal Created Menus for use in flash applications. *New AS 3.0 DrupalSite Class Function

    */

    public function getMenu(mid:String, callback:Function, data:Object = null, reload:Boolean = false):Boolean 
    {

        if (MENUS[mid] && MENUS[mid] is Object && !reload) {
            log('DrupalSite: info: Using cache data for menu ' + mid);
            callback(data, MENUS[mid]);
            return true;
        }

        return startBlocking(callback, data, String(mid), 'menu.get', mid);

    }

So far so good, we can use this function and it starts blocking. Where it gets tricky is when the onData function is called and we are passed a result, Currently i am getting an empty object(that i can see).

// Added Conditional to onData function

            else if ( cmd =='menu.get' ){

            if(result is Object){

                trace(result);
                log('Menu found.');
                MENU = result;

            } else {
                log('No menu with that id found.');
            }
        }

I really dont understand what i am doing/not doing here. I dont receive any data back from drupal, but all the other services works fine. Has anyone dealt with getting menus that could give me a pointer of where I may be going wrong. Thanks

Comments

you don't really need to

amcc's picture

you don't really need to change the onData function, i've added a few new services as below

<?php
// search service
public function searchNodes(search_keys:String, callback:Function, data:Object = null, reload:Boolean = false):Boolean {
           
   return
startBlocking(callback, data, search_keys, 'search.nodes', search_keys, true);
           
}
?>

in your callback function make it accept 2 objects as you normally would for nodes or views - in this example you will be returned a search results object. Test this out for the menu example first before altering the onData function - all this is doing is arranging things nicely for you.

also check to see if you're passing the right things to the menu.get service by going here:
/admin/build/services/browse/menu.get

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: