Adding an options page

If you want to create an individual options page for your module, you can hook into PSN’s navigation menu.

<?php
public function bootstrap()
{
    // only if PSNs admin backend is accessed:
    if ($this->_pm->getAccess()->isPlugin()) {

        // load a new navigation tab after the service tab
        IfwPsn_Wp_Proxy_Action::add('psn_after_admin_navigation_service', array($this, 'addNav'));
    }
}

/**
 * Adds an item to PSN's backend navigation menu
 *
 * @param IfwPsn_Vendor_Zend_Navigation $navigation
 */
public function addNav(IfwPsn_Vendor_Zend_Navigation $navigation)
{
    $page = new IfwPsn_Zend_Navigation_Page_WpMvc(array(
        'label' => __('Example', 'psn_exm'), // label of the navigation tab
        'controller' => 'example', // points to controllers/PsnExampleController.php
        'action' => 'index', // the default action which will be loaded on the controller
        'module' => strtolower($this->_pathinfo->getDirname()), // the module's directory name, no need to change
        'page' => $this->_pm->getPathinfo()->getDirname(), // the module's directory name, no need to change
        'route' => 'requestVars' // do not change this
    ));
    $navigation->addPage($page);
}

This would result in a new Tab with the text of the label option.

Example page

Before you can access the page you must create the controller class defined in the controller option.

Controller

As in the example the controller option has been set to “example”, a request on the new page will result in the URI ”...page=post-status-notifier&controller=example...” which will look for the example controller object. So you have to create a new file in the subdirectory “controllers” of your module called PsnExampleController.php

Example
└ controllers
  └ PsnExampleController.php

The controller object must be named following this format: [controller_name]_Psn[controller_name]Controller. In this case of controller name “example” it must be Example_PsnExampleController (notice the capital first letter E).

<?php
class Example_PsnExampleController extends PsnApplicationController
{
    /**
     * Default action
     */
    public function indexAction()
    {
        $this->view->headline = __('Example admin page', 'psn_exm');
    }

Action

The indexAction method of the controller object is where the request will be routed if no action is defined in the URI or the GET parameter appaction is “index”.

The corresponding HTML template which will be rendered automatically be the index action must be placed in the subdirectory views applying this format: views/scripts/psn-[controller_name]/[action_name].phtml

Example
└ views
  └ scripts
    └ psn-example
      └ index.phtml