Results 1 to 6 of 6

Thread: Omni Slide Menu items from PHP array

  1. #1
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Omni Slide Menu items from PHP array

    1) Script Title: Omni Slide Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...lide/index.htm

    3) Describe problem:
    I am just trying to populate the menu options from a PHP array, something like this (of course this doesn't work)
    Code:
    <script>
    .
    .
    .
    menupos:'top',         // set side that menu slides in from (right or left or top)
    bartext:'MAIN MENU',       // bar text (the vertical cell) use text or img tag
    ///////////////////////////
    menuItems:[
    //[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header
    ["Tickets"], //create header
    <?
    $stage_arr = $db->DataSet("select * from mt_job_stage");
    $ct = 1;
    foreach($stage_arr as $arow){
    	echo '["'.$arow['stage'].'", "work_order_listing.php?sid='.$arow['stage_id'].'"],'
    	$ct++;
    }
    ?>
    ["Lois Images", "http://www.loisimages.com", "_new"],
    ["State Street Blues", "http://www.statestreetbluesstroll.com/","_new"],
    ["Media Jazz by Night", "http://www.mediajazzbynight.com/", "_new
    .
    .
    .
    </script>
    Thanks in advance

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    PHP doesn't work any differently in javascript than in HTML. The served code must still be valid. Also, at least on most servers, the file containing PHP code must have the .php extension, and be referenced that way by other files that use it. With a javascript served as PHP it is good (but usually not currently required) to declare the mime type with a PHP header.

    To see whether or not the served code in a file altered via the use of PHP follows the correct format, just use a browser like Opera or FF and view the file directly via its 'view source' to see how the file is being parsed by the browser.

    If you need more help:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think i didnt explain the problem properly. all i am trying to do is populate the menu from an php array. Usually something like the code below works
    Code:
    menuItems:[
    ["Tickets"],
    <?
    foreach($stage_arr as $arow){
    	echo '["'.$arow['stage'].'", "work_order_listing.php?sid='.$arow['stage_id'].'"],'
    }
    ?>
    ...rest of the menu JS
    but for some reason here it just give me a blank page, even if i look at the source it blank. So the question is what am i missing

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Sounds like it isn't finding anything to echo. If there is no error, it either isn't parsing on the server side, or there's nothing to parse on the server side. Strict PHP requires a semicolon at the end of a line like echo and at the end of the foreach closure, and a formal opening <?php tag, but none or some that might not matter here. I'm also not certain you got all of the preconditions I laid out in my previous post, though you may. In any case, to be of any real help, I'd want a link to your page:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i got it going ... I appreciate all the help guys. DD rocks

  6. #6
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    how do i go about adding images to omni menu?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •