PHP在视图文件中调用zend调用控制器方法

时间:2013-05-14 16:48:42

标签: php zend-framework

我的控制器:

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

    public function indexAction(){
        die();
    }

    public function reportAboutExpiringPaymentAction(){
    }
}

如何从file.phtml

调用reportAboutExpiringPaymentAction()

2 个答案:

答案 0 :(得分:0)

您需要的方式根本不起作用。在phtml上调用此函数的唯一方法是这样的:
网址如下:http://www.yoursite.com/cron/report-about-expiring-payment
代码是:

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

    public function indexAction(){
        die();
    }

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

答案 1 :(得分:0)

您可以使用View Actions helper从视图中调用操作。在您的情况下,<?php echo $this->action('reportaboutexpiringpayment','cron',null); ?>将执行操作