Tree hierachy : Make it stick between refreshes!

Discussion in 'Tips/Tricks/Mods' started by djtremors, Feb 28, 2007.

  1. djtremors

    djtremors ISPConfig Developer ISPConfig Developer

    Hi all,

    I decided to do something constructive and hence came up with this cookie routine patch for the tree view.

    This was done on 2.2.9 and would work on any version of ISPConfig. I will soon create a straight replacement file version on my website when possible as I'm rebuilding my site.

    there's 3 sections to my patch.
    1. Add the extra functions javascript code for cookie reading/writing.
    2. Force the tree loop to check for saved settings and apply them.
    3. Set the Write settings to the cookie. when each branch is clicked.

    Here's the catches
    1. The top expand/collapse do not work currently (will be fixed later)
    2. First time open, all folders are expanded.
    3. These changes so far are session based. close the page and the changes are lost. permanent is available on request

    Here is my patch

    These 3 were done in the /home/admispconfig/ispconfig/web/isp_manager/inhalt_tree.php and seem to work fine. It could also be applied to the other inhalt_tree files which have the same annoying issue.

    Below: Add this anywhere in a valid area at the top next to other javascript functions.
    <!-- patch_startAdded cookie functions -->
    createCookie(name,value,days) {
        if (
    days) {
    date = new Date();
    expires "; expires="+date.toGMTString();
        else var 
    expires "";
    document.cookie name+"="+value+expires+"; path=/";

    readCookie(name) {
    nameEQ name "=";
    ca document.cookie.split(';');
    i=0;ca.length;i++) {
            while (
    c.charAt(0)==' 'c.substring(1,c.length);
            if (
    c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    patch_endAdded cookie functions -->
    Below: Search for the function maleVerz and add the section with the "patch" section
    function maleVerz(startEintrag,zweigEintrag) {
            VerzAuf = '<? echo htmlspecialchars($go_api->lng("Verzeichnis �ffnen"))?>'
            VerzZu = '<? echo htmlspecialchars($go_api->lng("Verzeichnis schliessen"))?>'
            var nachfolger = sucheNachfolgerVon(startEintrag);
            var aktuellerIndex = 1;
            while (aktuellerIndex <= nachfolger.laenge) {
     <!--patched_start: Apply the cookie to the tree -->
                    checkval = readCookie("mgr_"+nachfolger[aktuellerIndex].name);
                    nachfolger[aktuellerIndex].offen = checkval;
    <!--patched_end: Apply the cookie to the tree -->
    Below: Either replace the function with lines below or just add the createCookie line in the exact section.
    <!-- patch_startstatus change added cookie writing -->
    aufzuVerz(name,status) {
    eintragsIndex indexVonEintrag(name);
    menuDaten[eintragsIndex].offen status;
    timeOutname setTimeout("maleMenu()",100);
            if ((
    status == 1) && (menuDaten[eintragsIndex].url != '')) {frames["seiteFrame"].location.href=menuDaten[eintragsIndex].url}}
    patch_endstatus change added cookie writing -->
    Last edited: Feb 28, 2007

Share This Page