1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect2 id="zend.navigation.pages.factory">
4 <title>Creating pages using the page factory</title>
7 All pages (also custom classes), can be created using the page
8 factory, <methodname>Zend_Navigation_Page::factory()</methodname>. The factory
9 can take an array with options, or a
10 <classname>Zend_Config</classname> object. Each key in the
11 array/config corresponds to a page option, as seen in the
12 section on <link linkend="zend.navigation.pages">Pages</link>.
13 If the option <code>uri</code> is given and no <acronym>MVC</acronym> options are
14 given (<code>action, controller, module, route</code>), an <acronym>URI</acronym>
15 page will be created. If any of the <acronym>MVC</acronym> options are given, an
16 <acronym>MVC</acronym> page will be created.
20 If <code>type</code> is given, the factory will assume the value to
21 be the name of the class that should be created. If the value is
22 <code>mvc</code> or <code>uri</code> and <acronym>MVC</acronym>/URI page will be created.
25 <example id="zend.navigation.pages.factory.example.mvc">
26 <title>Creating an MVC page using the page factory</title>
28 <programlisting language="php"><![CDATA[
29 $page = Zend_Navigation_Page::factory(array(
30 'label' => 'My MVC page',
34 $page = Zend_Navigation_Page::factory(array(
35 'label' => 'Search blog',
37 'controller' => 'search',
41 $page = Zend_Navigation_Page::factory(array(
44 'controller' => 'index',
49 $page = Zend_Navigation_Page::factory(array(
51 'label' => 'My MVC page'
56 <example id="zend.navigation.pages.factory.example.uri">
57 <title>Creating a URI page using the page factory</title>
59 <programlisting language="php"><![CDATA[
60 $page = Zend_Navigation_Page::factory(array(
61 'label' => 'My URI page',
62 'uri' => 'http://www.example.com/'
65 $page = Zend_Navigation_Page::factory(array(
67 'uri' => 'http://www.example.com/search',
71 $page = Zend_Navigation_Page::factory(array(
72 'label' => 'My URI page',
76 $page = Zend_Navigation_Page::factory(array(
78 'label' => 'My URI page'
83 <example id="zend.navigation.pages.factory.example.custom">
84 <title>Creating a custom page type using the page factory</title>
87 To create a custom page type using the factory, use the option
88 <code>type</code> to specify a class name to instantiate.
91 <programlisting language="php"><![CDATA[
92 class My_Navigation_Page extends Zend_Navigation_Page
94 protected $_fooBar = 'ok';
96 public function setFooBar($fooBar)
98 $this->_fooBar = $fooBar;
102 $page = Zend_Navigation_Page::factory(array(
103 'type' => 'My_Navigation_Page',
104 'label' => 'My custom page',
105 'foo_bar' => 'foo bar'