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

  • Home
  • SEARCH
  • 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 3344468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:04:23+00:00 2026-05-18T01:04:23+00:00

I am new to ZF and I have problem with even simple tasks. I

  • 0

I am new to ZF and I have problem with even simple tasks.

I would like to have dynamically generated menu on every page. To do that I should fill $this->view with data. OK, but to do that, I would have to fill view separately in every controller I made. This would lead to code duplication.

The most natural solution, that I see, is to create base controller class for all my controllers, but I read, that this is not a good practice in ZF. So how should I do that? Even if it is only one line of duplicated code (eg. $this->view->menu = $reusableObject->generateMenuData()), I don’t like it.

What is the best practice for such a solution? How could you solve this problem?

I am using ZF 1.11.

EDIT: I would like to mention, that I would be happy to know how to do that using some kind of phtml file rather than concatinating html tags.

EDIT2: The point is, I am not really interested in only navigation links. Instead of menu with links that could be eg. list of latest post, but on every page, so in every controller. I am particularly interested in “how to this kind of stuff in ZF”.

  • 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-18T01:04:24+00:00Added an answer on May 18, 2026 at 1:04 am

    Zend Framework has a Navigation component:

    Zend_Navigation is a component for managing trees of pointers to web pages. Simply put: It can be used for creating menus, breadcrumbs, links, and sitemaps, or serve as a model for other navigation related purposes.

    It also has some ViewHelpers to render various navigational elements out of it:

    • Breadcrumbs, used for rendering the path to the currently active page.
    • Links, used for rendering navigational head links (e.g. )
    • Menu, used for rendering menus.
    • Sitemap, used for rendering sitemaps conforming to the » Sitemaps XML format.
    • Navigation, used for proxying calls to other navigational helpers.

    To prevent code duplication, use a Controller plugin that configures the Zend_Navigation instance and sets it to View or use Zend_Application_Resource_Navigation to configure it from your application.ini, which will then automatically assign it to the View Helpers.

    Re your EDITs

    You can use Zend_Navigation for arbitrary menues, not just the main navigation. Just configure it as you see fit and then render it with the appropriate helper. And if none of the Navigation helpers are what you are looking for, just write a helper or a partial that does the required output.

    Whether you use a Controller Plugin to configure and inject it into the View or use a Helper that queries the Model for your Blog Post in the View Layout is up to you. Both is equally fine and possible.

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

Sidebar

Related Questions

I'm quite new to C#, so I might have a problem that C# has
I have a strange problem with the <ui:repeat> tag. Even for my very simple
I have new problem. My code: .method public static void Main() cil managed {
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem on my blog: http://osify.com while processing add new post with above
I have problem with Qt::Tool flag. When I create new widget with Qt::Tool flag
I do not have problem as such but I am quite new to Ruby.
I am new on iphone development and I have problem with CoreData. I hardly
I'm new in codeigniter I have problem I use my OS X Lion, and
i have a problem to add a new attribute to an existing html string.

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.