0

I'm new to Zend and I have some questions: I will try to simplify the exemple. I have created a global vaiable in the bootstrap and set it to false

    Zend_Registry::set('var1', FALSE);

and I have created a file Translate.php:

<?php

class CMS_Application_Resource_Translate extends Zend_Application_Resource_ResourceAbstract {

public function my_function() {
    //do Something
    }

}

And in every controller I put this code:

 public function init()
{
if (Zend_Registry::get('var1')) {
   $instance1=new CMS_Application_Resource_Translate();
   $instance1->my_function();
}
}

And I have created a button that figured in all the site pages, when I click on this button, I want to set the global variable to true, so that the init() function of the controllers work. But I have a problem: How can I execute a function that changes the global variable to true on click on the button?

4
  • 1
    PHP is server side, it has no concept of button clicks. You'll either have to submit a form or do an AJAX request.
    – GordonM
    Dec 13, 2012 at 13:16
  • @GordonM Should I get/set the global variable with an ajax request? I can not do it otherwise?
    – Aminesrine
    Dec 13, 2012 at 13:22
  • can I pass the variable through the url localhost/controller/action/var1=true??
    – Aminesrine
    Dec 13, 2012 at 13:29
  • @Bouaziz ,of course you can just append ?var1=true after the .../action and simply query the request object in the bootstrap to set the property
    – shawndreck
    Dec 16, 2012 at 3:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.