Code

JQuery Tree's branches closing

For those who already work with JQuery Tree plugin, maybe you need to open only one branch at time, closing others. Here is how I resolved this problem :

  $('#tree').tree({
    callback: {
      onOpen: function(NODE, TREE_OBJ) {
        // fermeture des branches suivantes
       closeNextBranches(TREE_OBJ.next(NODE, true), TREE_OBJ);
        // fermeture des branches précédentes
        closePrevBranches(TREE_OBJ.prev(NODE, true), TREE_OBJ);
      }
    }
  });
  function closeNextBranches(NODE, TREE_OBJ) {
    TREE_OBJ.close_branch.call(TREE_OBJ, NODE);
    if (TREE_OBJ.next(NODE, true) != false) {
     closeNextBranches(TREE_OBJ.next(NODE, true), TREE_OBJ);
    }
  }
  function closePrevBranches(NODE, TREE_OBJ) {
    TREE_OBJ.close_branch.call(TREE_OBJ, NODE);
    if (TREE_OBJ.prev(NODE, true) != false) {
      closePrevBranches(TREE_OBJ.prev(NODE, true), TREE_OBJ);
    }
  }

I hope this piece of code will help you. Don't hesitate to give me other solutions.

Zend menu generator

Here I present you a menu generator for Zend applications. The key feature is the integration with ACL rules.

It is composed  of three files :

  • menu.ini, contain menu description;

  • showMenu.php, helper to display menu;

  • menu.css, CSS stylesheet.

Menu.ini

; Patient

patient.name = Patient
patient.controller = patient
patient.action = show-list
patient.sub.add.name = Register new
patient.sub.add.controller = patient
patient.sub.add.action = add
patient.sub.list.name = Manage patients
patient.sub.list.controller = patient
patient.sub.list.action = show-list
patient.sub.quittance.name = Register quittance
patient.sub.quittance.controller = quittance
patient.sub.quittance.action = add

; Test
test.name = Test
test.controller = test
test.action = show-list
test.sub.add.name = Register new
test.sub.add.controller = test
test.sub.add.action = add
test.sub.list.name = Manage tests
test.sub.list.controller = test
test.sub.list.action = show-list

ShowMenu.php

It is the helper. Download it.

menu.css

This is the css for a css only menu. It is included in the ShowMenu.zip file. I found it on a website, but I don't remember the name. Sorry.

I hope you will enjoy. You are free to modify this code. If you do, I will appreciate to know it.

Syndicate content