Search code examples
zend-frameworkzend-navigation

Zend_Navigation_Container set separator


Is there a way when using Zend_Navigation to set a separator for pages?

For example, I call $this->navigation()->menu() in my view to render a navigation menu in a form of an unordered list. I would like there to be a separator between all menu items, for example |.

So, every menu item which is not last, would end with:

</a> | </li>

Solution

  • You can do it in CSS like this.

    li:before {
        content: "|";
    }
    
    li:first-child:before {
        content: "";
    }
    
    li:first-child a {
        margin-left: 0;
    }
    
    li a {
        margin: 0 0 0 2mm;
    }
    

    The reverse logic here is for browser compatibility. IE < 9 doesn't support last-child but supports first-child.