PhpRiot
Follow phpriot on Twitter
Sponsored Link
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
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Adding pages

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

Example 617. 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);

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

Zend Framework