Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7458551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:27:45+00:00 2026-05-29T13:27:45+00:00

I am working through a Zend framework book and is stuck for days on

  • 0

I am working through a Zend framework book and is stuck for days on the example where I change the default view location. The method is as listed:

$this->view->setScriptPath("/views/");
$this->render("news");

I place my news.phtml file in the views directory(rather than the default views/scripts/artist but all I got was a message that says the page is not found. I have tried many methods from the web, such as typing

$this->view->setScriptPath("/application/views/");

or

$this->view->setScriptPath(APPLICATION_PATH."/views/");

but all are not working.

Can someone please enlighten me?


To improve the clarity, I kind of suspect it got to do with my machine setup. I am running on Mac 10.7 and I have activated the built-in PHP and Apache. Since Zend provides it’s own stack, will there be any clash in the setting files such as php.ini?


More edits:
I am putting down the whole method:

public function newsAction()
{
    //Check if the user is logged in

    //Get the user's id
    //
    //Get the artists
    $artists = array("Thievery Corporation",
        "The Eagles",
        "Elton John");

    //Set the view vairables
    $this->_helper->viewRenderer->setRender('news');
    $this->view->setScriptPath(APPLICATION_PATH.'/views/');
    $this->_helper->viewRenderer->setNeverController(true)->setRender('news');
}

I placed the news.phtml in the views directory. The URL I type is http://localhost:10088/loudbite/artist/news. The artistController is in the controllers folder. Still doesn’t work.
What is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:27:45+00:00Added an answer on May 29, 2026 at 1:27 pm

    When using setScriptPath() or addScriptPath, you need to specify the absolute path to the directory, or a path relative to your current directory. For portability, using an absolute path is best.

    When calling Zend_View::render() you must pass the script name including its extension.

    Based on your last example, try something like this:

    $view->setScriptPath(APPLICATION_PATH . '/views/');
    $html = $view->render('news.phtml');
    

    Just make sure to get the path correct. My example assumes you have views in your application folder.

    EDIT:
    If you are in a controller and you want to use a different view script, use the View Renderer helper instead:

    $this->_helper->viewRenderer->setRender('news');
    

    This tells the view renderer to look for a view script news.phtml instead of the name of your action. However, it still looks in views/scripts/controller/ for news.phtml. Therefore you need the following changes as well:

    // set view script path to the base of the views folder
    $this->view->setScriptPath(APPLICATION_PATH . '/views/');
    
    $this->_helper
         ->viewRenderer
         ->setNeverController(true) // do not render into controller subdirectories
         ->setRender('news');       // set render script to news.phtml
    

    When you are using Zend Application, it does its own view rendering, so unless you are trying to render html for use directly, you shouldn’t use Zend_View yourself. After your controller action method completes, Zend Application is going to automatically render a view script and attempt to output it, along with any layout to the browser. If you did create your own Zend_View, you would need to terminate the request before the action finishes, as not to render any other content. There are also ways to disable the layout or view rendering as an alternative.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working my way through the Apress book Beginning Zend Framework - and am
I'm working through the book Zend Framework - A beginners guide. Part of the
Working through a zend tutorial & get this message, & not sure where to
Working through more book examples- this one is a partial poker program- This segment
Working through this for fun: http://www.diku.dk/hjemmesider/ansatte/torbenm/Basics/ Example calculation of nullable and first uses a
I'm working through this build-a-JavaScript-framework tutorial . Why in the following code is $super
I'm working my way through Zend Framework: A beginners guide by Vikram Vaswani, and
I'm working on a zend framework based email project and I'm following some code
I'm working on a Zend Framework project where I've stumbled across a bit of
Working through Pro ASP.NET MVC book and I got the following code snippet that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.