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 7777847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:14:46+00:00 2026-06-01T18:14:46+00:00

I have a working zend mvc application that is using a layout, and this

  • 0

I have a working zend mvc application that is using a layout, and this layout uses external stylesheets and scripts. Each page in the site has it’s own controller, and the page-specific content for each page is in its index.phtml file. The layout works, and all the scripts/stylesheets are properly applied for each controller’s index.phtml.

For example, the home page is “mvcProject/” which calls the index controller’s index action which uses the index.phtml file respective to the index controller. Futhermore, the about us page is “mvcProject/about” which calls the about controller and displays views/about/index.phtml. Subjectively I felt that this structure was inefficient. The content of this site is only html, and I can’t see why each page needs its own controller.

Therefore I tried to use only one controller to achieve the same end, that is to have the same architecture, by giving each page its own action within the single index controller. So now the “about us” page was “mvcProject/index/about” so that the index controller would call the about action which would use the views/index/about.phtml file.

This approach broke all of the links to external scripts/stylesheets in the layout. The layout still worked, but none of the links’ paths would work. Obviously, this is a path-related issue, but I’m still relatively new to zend so I wasn’t sure how to fix this. Therefore I went back and gave each page it’s own controller again.

So my question is two fold: do I need concern myself with avoiding the bloat of giving each page its own controller, and if I do need to slim this structure down, what do I need to adjust to correct the links’ paths? Thanks for your consideration.

  • 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-06-01T18:14:47+00:00Added an answer on June 1, 2026 at 6:14 pm

    Ignoring the discussion about the framework/number of controllers is overkill for now. The reason your scripts/css are failing is indeed a path issue. If you are using the layout helper then you should make use of the headLink and headScript objects inside the view.

    This is my preferred way of setting up the scripts and css files I need whilst developing.

    Bootstrap.php

    protected function _initView()
    {
        // Initalise the view
        $view = new Zend_View();
        $view->doctype('HTML5');
    
        // Get config options for the UI
        $ui = $this->getApplication()->getOption('ui');
    
        $view->headTitle($ui['title']);
    
        foreach ($ui['stylesheet'] as $stylesheet) {
            $view->headLink()->appendStylesheet($stylesheet);
        }
    
        foreach ($ui['script'] as $script) {
            $view->headScript()->appendFile($script);
        }
    
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
                'ViewRenderer'
        );
        $viewRenderer->setView($view);
    
        return $view;
    }
    

    configs/application.ini

    ui.title = "My Awesome Web App"
    ui.stylesheet[] = "/extjs/resources/css/ext-all.css"
    ui.stylesheet[] = "/resources/css/hod.css"
    ui.stylesheet[] = "/resources/css/icons.css"
    ui.stylesheet[] = "/resources/bootstrap/css/bootstrap.css"
    ui.script[] = "extjs/ext-debug.js"
    ui.script[] = "app.js"
    

    layouts/default.phtml

    <?php echo $this->doctype(); ?>
    <html>
    <head>
        <?php
        echo $this->headTitle();
        echo $this->headMeta();
        echo $this->headStyle();
        echo $this->headScript();
        echo $this->headLink();
        ?>
    </head>
    
    <body>
        <?php echo $this->layout()->content; ?>
    </body>
    </html>
    

    This allows you to setup all the scripts you need in development mode, and set the minified scripts in production all in the config without having to write any extra code.

    Going back to the overkill question. I think even if you don’t have connections to the database and all the bells and whistles in your app, using a framework is still the best approach from a maintenance point of view (once you’re up to speed with the framework that is) if you are going to have more than 5 or 6 pages. Unless your website is going to see huge volumes of traffic and every byte or ms counts, then I don’t see the point in reducing maintainability for the small overhead a framework adds.

    The same logic applies for me with controllers. I don’t see why you want to reduce the number of them when they help clearly split up the functions of work. Plus unless you change the router site.com/index/about looks uglier than site.com/about 🙂

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

Sidebar

Related Questions

A set of forms (using Zend_Form) that I have been working on were causing
I have been working on a new installation of a Zend Framework application for
I'm working on Zend application, but have no much experience with Zend, so just
Im working on a what I thought would be simple application using zend framework.
I have a problem with Zend 3 step layout. Its working as it should
I am working on zend. I have a form with some checkboxes. I want
I have working registration script the only problem is that i do not know
Have been working on this question for a couple hours and have come close
I have a calendar application, and in that calendar application, there is a mini
I am working with Zend framework and just hate the fact that I seem

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.