6 Replies Latest reply on Apr 13, 2008 6:31 PM by ChiefRocka00

    Load menubar from a php call

    ChiefRocka00 Level 1
      I am trying to populate a menubar from a PHP call. I have all the menu options and their children stored in a database and want to get them out and dynamically populate the menubar. I feel like this should be straight forward but I have spent a couple hours on this so far and have had no luck. Any help would be GREATLY appreciated!!!
        • 1. Re: Load menubar from a php call
          ntsiii Level 3
          Generate an xml structure and pass it back to flex. Menubar can consume this directly, but you need to assign the dataProvider an XMLList. like

          private function onResult(event:ResultEvent):void {
          var xmlMenuitems = XML(event.result);
          var xlMenuitems:XMLList = xmlMenuitems.menuitem;
          myMenuBar.dataProvider = xlMenuitems;

          Tracy
          • 2. Re: Load menubar from a php call
            ChiefRocka00 Level 1
            How should the XML be formatted? I have tried formatting it two different ways, one way it does nothing and the other way I get a message saying it is improperly formatted xml. The two ways I have tried are:

            THIS ONE DID NOTHING:
            <root>
            <menuitem>
            <label>Commercial</label>
            <data/>
            <menuitem>
            <label>1425 Mendell Street Offices</label>
            <data>9</data>
            </menuitem>
            <menuitem>
            <label>Corkage Wine Bar</label>
            <data>10</data>
            </menuitem>
            <menuitem>
            <label>Montclair Hardware Store</label>
            <data>11</data>
            </menuitem>
            </menuitem>
            </root>

            and THIS ONE SAYS IT IS IMPROPERLY FORMATTED XML:
            <menu>
            <menuitem label='Commercial'>
            <menuitem label='1425 Mendell Street Offices' data='9'/>
            <menuitem label='Corkage Wine Bar' data='10'/>
            <menuitem label='Montclair Hardware Store' data='11'/>
            </menuitem>
            </menu>

            Also, I am doing an HTTPService request, do I need to have the resultFormat="e4x"?

            Thank You Very Much!!!
            • 3. Re: Load menubar from a php call
              flexsea
              This one is invalid, since zou missed the '/' behind the 'Commercial':

              quote:

              <menu>
              <menuitem label='Commercial'>
              <menuitem label='1425 Mendell Street Offices' data='9'/>
              <menuitem label='Corkage Wine Bar' data='10'/>
              <menuitem label='Montclair Hardware Store' data='11'/>
              </menuitem>
              </menu>
              • 4. Load menubar from a php call
                ChiefRocka00 Level 1
                I am not closing the Commercial tag there, the close for that tag is after the Montclair Hardware Store tag, there is a parent/child relationship.
                • 5. Re: Load menubar from a php call
                  ntsiii Level 3
                  resultFormat="e4x"? Yes.

                  All the docs use the second format, using attributes ion the menuitems.

                  XML looks ok to me. Where do you get the error? Paste the xml into a text file with a .xml extension and open it with IE. that may tell you where the problem is.

                  Tracy
                  • 6. Re: Load menubar from a php call
                    ChiefRocka00 Level 1
                    Tracy,

                    I got the menu working... thank you very much for that!!! One additional question about the menubar, do you know how I could center the text in the middle of the menu bar? My customer wants the bar to extend horizontally across the entire page but they only have five menu options and want them center on the menu bar.

                    Thanks,
                    Tedd