简体   繁体   中英

PHP call zend call controller method in view file

My controller:

class CronController extends Zend_Controller_Action {
    public function init(){
    }

    public function indexAction(){
        die();
    }

    public function reportAboutExpiringPaymentAction(){
    }
}

How can I call reportAboutExpiringPaymentAction() from file.phtml

The way that you need, doesn't work at all. Only way to call this function on a phtml is like this:
The URL is like: http://www.yoursite.com/cron/report-about-expiring-payment
And code is:

class CronController extends Zend_Controller_Action {
    public function init(){
    }

    public function indexAction(){
        die();
    }

    public function reportAboutExpiringPaymentAction(){
        /* YOUR CODE HERE */
        $this->render('file.phtml');
    }
}

You can use View Actions helper to call an action form the view. In your case <?php echo $this->action('reportaboutexpiringpayment','cron',null); ?> <?php echo $this->action('reportaboutexpiringpayment','cron',null); ?> will execute the action

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM