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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:45:05+00:00 2026-05-13T23:45:05+00:00

In my View (using Zend_View so the the view is an object), I make

  • 0

In my View (using Zend_View so the the view is an object), I make calls to object properties and methods to populate the template like so:

<?= $this->user->name ?> // Outputs John Doe
<br/>
<?= $this->user->getCompany()->name ?> // Outputs Acme
<br/>
<?= $this->method() ?> // Outputs foobar

If I make it so that all property requests (like for ‘user’) go through __get() is there any way that I can catch the subsequent calls so that I can force a method call on the final outputted value? For example so that I could do automatic escaping of output.

As I see it right now, I either have to escape the input as it goes into the database or use compiled templates like Smarty does, or switch to assigning every variable to the View object so that it has direct control to force escaping before outputting the data.

  • 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-13T23:45:06+00:00Added an answer on May 13, 2026 at 11:45 pm

    You could use a decorator. See this simplified example:

    class ViewObject_Decorator
    {
        protected $_decoratedObject;
    
        protected $_view;
    
        public function __construct( $object, Zend_View view )
        {
            $this->_decoratedObject = $object;
            $this->_view = $view;
        }
    
        public function __get( $property )
        {
            return $this->_view->escape( $this->_decoratedObject->$property );
        }
    
        /*
            maybe implement __call to proxy to decoratedObject methods, etc...
        */
    }
    

    Then your proposed __get method (presuming this is a Zend_View method?) would be something like:

    public function __get( $property )
    {
        // decorate the requested object, and send the view along with it.
        return new ViewObject_Decorator( $this->$property, $this );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Zend_View to template text email content. However, I've come across one problem
I have finally got a zend view helper working using this in my helper
I am using Zend Framework. Want to make a portlet kind of view, which
I have tried to embed a flash movie in a zend view using the
Can someone help me achieve multiple zend pagination in a view using ajax. I
In my MVC view (using VS 2012 RC), I'm attempting to use jQuery to
I have created navigaton view using Sencha touch 2. Navigation view has list component
I have HTML view using 2010 .NET, which I am generating in the report
I'm trying to color my view using css. The controller is workflows_controller. Hence i
I want to render the partial view using ajax. When I submit the button,

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.