Hello all
I am a total newbie and I am trying to get to grips with the zend framework and php. I am trying to call "http://localhost/artist/new" to bring up a submission form to add music artists but im getting directed to the wrong view and cant figure out why.
I have got an Artist controller with actions that include newAction() and profileAction() and a views folder with artist folder and files new.phtml and profile.phtml. When I try get the view "http://localhost/artist/new" my web browser is bringing up the profile.phtml file instead of the new.phtml file.
In my ArtistController I have a blank method for profileAction and the following code for newAction():
public function newAction()
{
//Get all the genres
$genres = array("Electronic","Country","Rock","R & B","Hip-Hop","Heavy-Metal","Alternative Rock","Christian","Jazz","Pop");
//Set the view variables
$this->view->genres = $genres;
}
An in my views folder under artist i have a new.phtml file with code for a form and a blank profile.phtml file.I am thinking the problem maybe something to do with my index.php file where Ive got the following code and maybe its something to do with the router:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?
getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
/** Routing Info **/
$FrontController = Zend_Controller_Front::getInstance();
$Router = $FrontController->getRouter();
$Router->addRoute("artistprofile",
new Zend_Controller_Router_Route(
"artist/:artistname",
array
("artistname" => "The Smiths",
"controller" => "artist",
"action" => "profile"
)));
$Router->addRoute("artiststore",
new Zend_Controller_Router_Route(
"artist/store",
array
("controller" => "artist",
"action" => "artistaffiliatecontent"
)));
$application->bootstrap()->run();
Can anyone help me??????????????