Re: Tree menu list in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I'd like to write my opinion quickly.. My way both usable with and without
JS...

In my structures there is an array of the menu elements similar to:
$menu[gravity][name] = link; - filled from database, easy to handle

to more prof., more params use three-dimensional array...

In the url u can store the selected/expanded (sub)menu but without js its a
little bit slow cause of reload. (good way if js is blocked and users have
high speed conn. or page cached well...)
eg. home?expand=menu_item_id
if (this_menu_item == expanded_item){
  show submenus...
}

u can also generate js from php.. or set height, visibility from js for a
*div uploaded from php*...
create an array or use simple innerHTML to show the menu... I suggest
skipping all the js examples (because they are too complicated) and write a
simple script from your mind using basic elements...

eg. simply you have to have a global array...
expanded[menuid] = true;
if (expanded[menuid]){
   //innerHTML = "submenus";
   menu_item.style.height = "auto";
   menu_item.style.visibilty = "visible";
}

or expanded[] = id; //using in_array...

and yes, u can use AJAX to load php to js...

Simple JS code I wrote before it:
function subs(id, len){
    var subsa = document.getElementById(id);
    var subsap = document.getElementById(id + 'p');
    if (subss[id] == true){
        subsa.style.visibility = "hidden";
        subsa.style.height = "10px";
        subsap.innerHTML = "[+]";
        subss[id] = false;
    } else{
        subsa.style.height = (len * 18) + "px";
        subsa.style.visibility = "visible";
        subsap.innerHTML = "[-]";
        subss[id] = true;
    }
}

used for:
Menu[-]
 Sub
 Sub
Menu[+]
Menu[+]


*Have a good time with PHP!*


*Valentine*

On Tue, Jul 26, 2011 at 8:41 PM, alekto <alekto.antarctica@xxxxxxxxx> wrote:

> Thank you all for good answers and explanations, think I will give
> JavaScript a try!
>
>
>
> Den 26. juli 2011 kl. 20.37 skrev Bojan Tesanovic:
>
> > Look at it this way, PHP is just another scripting language, it processes
> data.
> > That said PHP is not responsible for user interface , it just prints out
> what you tell him to , it can be HTML XML JSON etc
> > presentation thing is eg HTML and CSS is for styling HTML, JS is to
> dynamically change structure of HTML or better to say DOM.
> > Though there is a easy way to make menus with HTML5 and CSS3 but most
> current browsers don't support those new tech stuff , (most browsers do but
> user are not up to date with freshest ones)
> >
> > If there is a real reason not to use JS, can you make more specific
> example so we can help.
> >
> > Bojan Tesanovic
> > Senior PHP Developer
> > http://oophp.org/
> >
> > On Jul 26, 2011, at 7:20 PM, alekto wrote:
> >
> >> Hi,
> >> is there a way to create a tree menu list only by using php/html/css?
> >> I found some, but they are all in JavaScript, do I have to make them by
> using JavaScript or is there a way in php as well?
> >>
> >> This is how I imagine the tree menu should look like:
> >>
> >>
> >> v First level
> >>> Second level
> >>> Second level
> >>    v Second level
> >>> Third level
> >>> Third level
> >>> Third level
> >>> Second level
> >>> Second level
> >>
> >> ( > = menu is closed, v  = menu is open )
> >>
> >>
> >> Cheers!
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >
> >
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux