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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:13:18+00:00 2026-06-05T18:13:18+00:00

in order to avoid copy/paste, i can use a unique view for different actions,

  • 0

in order to avoid copy/paste, i can use a unique view for different actions, i can do this using one of these ways

$this->renderScript('index/index.phtml'); 
$this->view->var = "hello world";   

or

$this->_helper->viewRenderer('index');
$this->view->var = "hello world";

if i want to use a different controller i have to use the 1st one, the viewRenderer is ok, but when i use the renderScript it shows nothing like var is not defined. how can i assign values to the view script?

index.phtml would be somthing like this

echo $this->var ;

  • 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-05T18:13:20+00:00Added an answer on June 5, 2026 at 6:13 pm

    It should work the way you described it

    class IndexController extends Zend_Controller_Action
    {
    
        public function init()
        {
            /* Initialize action controller here */
            $this->view->var = 'echo me in any action viewscript and i will show you text';
        }
    
        public function indexAction()
        {
            // action body
            $this->view->test = 'Don\'t put me here becuase this is not the action that is run';
    
        }
    
        public function testAction()
        {
            // action body
    
            $this->view->test = 'Hello world';
            $this->renderScript('index/index.phtml');
            // or $this->_helper->viewRenderer('index');
        }
    
    }
    

    in my view (index.phtml)

    i have

    <?php echo $this->test;?> 
    

    When i go to /index/test/ it will show “hello world”…

    Also when i do it in another controller it gives me the result

    class MyController extends Zend_Controller_Action
    {
    
        public function init()
        {
            /* Initialize action controller here */
        }
    
        public function indexAction()
        {
            // action body
            $this->view->test = 'Hello world';
            $this->renderScript('index/index.phtml'); 
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never written copy constructor, so in order to avoid pain i wanted
In order to avoid namespace bloating, I use packages. For example, let Foo be
I am trying to use the special variable .RECIPEPREFIX in order to avoid the
In order to avoid soft delete I am creating a recycle bin database. The
In order to work with decimal data types, I have to do this with
rails 2.3.4, sqlite3 I'm trying this Production.find(:all, :conditions => ["time > ?", start_time.utc], :order
I'm going to use SQLite in order to save a lot of data in
In order to help avoid unnecessary heap allocations of strings inside a class, I
in order to avoid an include circle, I have replaced an #include that was
I usually create parameterized queries in order to avoid SQL Injection attacks. However, I

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.