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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:10:50+00:00 2026-05-13T14:10:50+00:00

Given an html/javascript ‘widget’ which needs to have certain fields customized before use. For

  • 0

Given an html/javascript ‘widget’ which needs to have certain fields customized before use. For example, the css class ids need to be unique as the widget may appear more than once on the same page.

Let’s say I want to keep the markup (js/html) of the widget stored as a template so that I can fill in the values that need to be customized during resuse.

I know that Zend Framework’s views give you at least part of this functionality, but each view is generally associated with a particular controller. Given that this widget could be created from any controller, yes still needs to be able to access some properties stored in a controller (or model). Where should I put the widget markup and how then do I fill in the custom values?

Can I create a custom view that can be reused within the same page (appear more than once) as well as on other pages? If so, how do I set that up?

  • 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-13T14:10:50+00:00Added an answer on May 13, 2026 at 2:10 pm

    Sounds like you need a ViewHelper http://framework.zend.com/manual/en/zend.view.helpers.html. Create a custom helper that will fetch the data from a model and just simply output it. This way it won’t depend on any controller, can be called in either the layout or in any view script. Example:

    // views/helpers/Widget.php
    class Zend_View_Helper_Widget extends Zend_View_Helper_Abstract
    {
    protected $_model = null;
    
    protected $_view = null;
    
    public function widget()
    {
        $data = $this->_getDataFromModel();
    
        return $this->_view->partial('widget.phtml', array('data' => $data));
    }
    
    public function setView(Zend_View_Interface $view)
    {
        if($this->_view === null) {
            $this->_view = $view;
        }
    
        return $this->_view;
    }
    
    protected function _getDataFromModel()
    {
         $this->_model = $this->_getModel();
         return $this->_model->getDataForWidget();
    }
    
    protected function _getModel()
    {
         if($this->_model === null) {
             $this->_model = new Model_Widget(); // or whatever it's called
         }
         return $this->_model;
    }
    

    The partial script:

    // views/scripts/widget.phtml
    <div class="widget-class"><?php echo $this->data; ?></div>
    

    And when you need it in your views just call it like <?php echo $this->widget(); ?>

    Note that I’m rendering the widget in a separate partial view script, just to avoid having html/css in the helper itself.

    Hope this helps to get you started 🙂

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

Sidebar

Related Questions

How would one create a deterministic Javascript HTML colour picker which given arguments of
I've been given a prototype/mockup of a grid written in html and javascript (via
I have the HTML given below: <ul id=thumbsPhotos> <li src=/images/1alvaston-hall-relaxing-lg.jpg onclick=updatePhoto (this.title)><img src=/images/1alvaston-hall-relaxing-sl.jpg width=56
I'm looking for a single line regex which does the following: Given a HTML
Given this HTML: <ul id=topnav> <li id=topnav_galleries><a href=#>Galleries</a></li> <li id=topnav_information><a href=#>Information</a></li> </ul> And this
Given a HTML file with the structure html -> body -> a bunch of
Given an HTML page that has a complex table-based layout and many tags that
Given this HTML: <div>foo</div><div>bar</div><div>baz</div> How do you make them display inline like this: foo
Given an HTML link like <a href=urltxt class=someclass close=true>texttxt</a> how can I isolate the
Given a html document, what is the most correct and concise regular expression pattern

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.