PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Adding pages

Adding pages to a container can be done with the methods addPage(), addPages(), or setPages(). See examples below for explanation.

Example 635. Adding pages to a container

<?php
// create container
$container = new Zend_Navigation();

// add page by giving a page instance
$container->addPage(Zend_Navigation_Page::factory(array(
    
'uri' => 'http://www.example.com/',
)));

// add page by giving an array
$container->addPage(array(
    
'uri' => 'http://www.example.com/',
));

// add page by giving a config object
$container->addPage(new Zend_Config(array(
    
'uri' => 'http://www.example.com/',
)));

$pages = array(
    array(
        
'label'  => 'Save',
        
'action' => 'save',
    ),
    array(
        
'label'  => 'Delete',
        
'action' => 'delete',
    ),
);

// add two pages
$container->addPages($pages);

// add container
$container->addPages(new Zend_Navigation(array(
    array(
        
'label'  => 'Move up',
        
'action' => 'up',
    ),
    array(
        
'label'  => 'Move down',
        
'action' => 'down',
    ),
)));

// remove existing pages and add the given pages
$container->setPages($pages);

Zend Framework