星期六, 6月 05, 2010

Zend View 常用動作

  1. jquery觸發submit
    $('form:first').trigger("submit");
  2. url路徑
    //根目錄 - 從web root到public
    $this->baseUrl('course/add'); //參數加入即會自動補
    =>/myweb/public/course/add
  3. 目前url
    $this->url(array('controller'=>'course','action'=>'add')); //如果當前的url是在同一個controller下的話,可以不用給controller參數
    =>/myweb/public/course/add/
  4. Controller, Action Name及參數
    $request = Zend_Controller_Front::getInstance()->getRequest();
    $controllerName = $request->getControllerName();
    $actionName = $request->getActionName();
    $paramArray = $request->getParams();
    $params = '';

    foreach($paramArray as $key => $value)
      $params .= $key . "/" . $value;
  5. 添加CSS 和 JS
    //將js,css放在public裡的js,css資料夾
    <script type="text/javascript" src="<?php echo $this->baseUrl('js/jquery-xxx.min.js');? >" >
    </script?>
    <link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl('css/xxx.css'); ? >" >
References
Zend - Get everything after base Url (Controller, Action, and any params)

沒有留言: