+ Reply to Thread
Results 1 to 3 of 3

Thread: Zend_view navigation menu baseUrl

  1. #1
    whisher is offline Member
    Join Date
    May 2009
    Location
    Kakiland
    Posts
    32

    Default Zend_view navigation menu baseUrl

    Hi.
    I'm having a look at
    Zend_Navigation ? creating a menu, a sitemap and breadcrumbs | free Zend Framework screencasts - Zendcasts
    btw excellent tutorial

    In a nutshell
    How can I put/get the baseUrl
    in the menu ?

    navigation.xml
    [PHP]
    <?xml version="1.0" encoding="UTF-8"?>
    <configdata>
    <nav>
    <home>
    <label>Home</label>
    <uri>/</uri>
    </home>
    <guestbook>
    <label>Guestbook</label>
    <uri>/guestbook/index</uri>
    </guestbook>
    </nav>
    </configdata>
    [/PHP]

    Bootstrap.php
    [PHP]
    protected function _initNavigation()
    {
    $this->bootstrap('layout');
    $layout = $this->getResource('layout');
    $view = $layout->getView();
    $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
    $container = new Zend_Navigation($config);
    $view->navigation($container);
    }
    [/PHP]

    layout.phtml

    [PHP]
    <?php echo $this->navigation()->menu(); ?>
    [/PHP]


    Output

    [PHP]
    <ul class="navigation">
    <li class="active">
    <a class="active" href="/">Home</a>
    </li>
    <li>
    <a href="/guestbook/index">Guestbook</a>
    </li>
    </ul>
    [/PHP]


    I'd like to get

    [PHP]
    <ul class="navigation">
    <li class="active">
    <a class="active" href="/zf/quickstart-zf/public/">Home</a>
    </li>
    <li>
    <a href="/zf/quickstart-zf/public/guestbook/index">Guestbook</a>
    </li>
    </ul>
    [/PHP]

    for instance.


    Bye.

  2. #2
    whisher is offline Member
    Join Date
    May 2009
    Location
    Kakiland
    Posts
    32

    Default

    [PHP]
    <?xml version="1.0" encoding="UTF-8"?>
    <configdata>
    <nav>
    <home>
    <label>Home</label>
    <controller>index</controller>
    <action>index</action>
    </home>
    <guestbook>
    <label>Guestbook</label>
    <controller>guestbook</controller>
    <action>index</action>
    </guestbook>
    </nav>
    </configdata>
    [/PHP]


  3. #3
    whisher is offline Member
    Join Date
    May 2009
    Location
    Kakiland
    Posts
    32

    Default

    For the active link
    [PHP]
    class IndexController extends Zend_Controller_Action
    {

    public function init()
    {


    $activeNav = $this->view->navigation()->findByController('index');
    $activeNav->active = true;
    $activeNav->setClass("active");

    }




    }
    [/PHP]

    It seems to work fine but I'd like to know
    your opinion


    I'm wondering if is there a way don't set it
    in all my controller ?

    Bye.
    Last edited by whisher; 06-04-2009 at 04:57 PM.

+ Reply to Thread

Similar Threads

  1. Zend_Navigation baseUrl creating bad URL
    By quantumm in forum Core Infrastructure
    Replies: 0
    Last Post: 02-22-2010, 06:12 PM
  2. Navigation Menu
    By FuZion in forum Concepts, Ideas, Planning
    Replies: 3
    Last Post: 11-06-2009, 08:52 AM
  3. problem with baseUrl and css
    By santamar1a in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 07-20-2009, 05:21 PM
  4. baseUrl questions
    By Howler9443 in forum General Q&A on Zend Framework
    Replies: 2
    Last Post: 04-11-2008, 04:35 PM
  5. BaseUrl problem - HELP
    By theDesignZoo in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 08-09-2007, 01:14 PM

Posting Permissions

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