oops jaime pas langlais openPNE常用方法分享

來源:互聯網
上載者:User
複製代碼 代碼如下:


'asdfgasgsad'));?>這句話意思是包含'_sidemenu.php'並往其頁面傳一系列參數,'_sidemenu.php'頁即可直接使用$form變數中的值
op_include_box('vote_question_create_box','asdfasdf',array('title'=>'建立問題','moreInfo'=>array('建立問題',link_to('建立問題2','@my_index'))));
?>
op_include_box('vote_question_create_box',get_slot('pager'),array('title'=>'建立問題','moreInfo'=>array('建立問題',link_to('建立問題2','@my_index'))));
?>
'vote_question_create_box'只是一個標記,'asdfasdf'或 get_slot('pager')則是要輸出到頁面上標題下的資訊(這個方法裡要包含slot只能用get_slot()不能用include_slot(),
而在頁面中要包含slot則必須使用include_slot())
第三個數組參數中的索引值名稱title是固定的,是該段'vote_question_create_box'顯示的標題,後面的'moreInfo'鍵名也是固定索引值對應的數組則是羅列顯示的內容列表
設定一個slot段落


包含指定的slot段落,設定的slot段落必須通過包含才能在頁面上顯示
op_include_form('vote_question_from',$form,array('title'=>'編輯問題','url'=>url_for('@vote_update?id='.$form->getObject()->getId()),));
?>包含一個表單對象,'vote_question_from'為標識名,$form為對應動作傳來的表單對象,第三個數組參數title索引值也url索引值是固定的,分別對應顯示的標題名和表單提交路徑
對應動作內容為
public function executeEdit(sfWebRequest $request){
$object = $this->getRoute()->getObject();
//如果不是作者螢幕上顯示404
$this->forward404Unless($this->getUser()->getMemberId() == $object->getMemberId());//$object->getMemberId()為傳遞過來的id值對應的那條記錄的member_id欄位值
$this->form = new VoteQuestionForm($object);
//訪問此移動路徑http://localhost/openpne/web/vote/edit/1
}
?>
用於分頁時前後翻頁的超連結
$pager來自動作裡的 $this->pager = Doctrine::getTable('VoteQuestion')->getListPager($request->getParameter('page'));
PluginVoteQuestionTable類getListPager()方法裡的內容↓
class PluginVoteQuestionTable extends Doctrine_Table
{
public function getListPager($page = 1,$size = 20)
{
$query = $this->createQuery()->orderBy('updated_at DESC');
$pager = new sfDoctrinePager('VoteQuestion',$size);//建立一個某表的分頁對象,並傳一個每頁顯示多少記錄值
$pager->setQuery($query);//傳一個查詢語句對象
$pager->setPage($page);//設返回顯示的頁數
$pager->init();
return $pager;
}
}
?>
對應前台頁面對分頁結果集的瀝遍
getResults() as $item): //利用openPNE分頁機制擷取指定分頁結果集並瀝遍每一條記錄?>


getUpdatedAt(),'f') //'f'代表一種顯示格式?>

getTitle(),count($item->getVoteAnswers())),'@vote_show?id='.$item->getId()) ?>



getId()) ?>相當於sdsfg
表名是駝峰模式在資料庫裡以底線表示,欄位名也是如此
連結的
就算不用方法也可以直接在action="此可直接寫web/後的====模組名/動作名====或路由中設定好的web後的路徑"
動作裡的
$this->tasksObject = $this->getRoute()->getObject();
$this->getRoute()->getObject();//擷取傳過來的id參數值對應的表中的那條資訊對象可通過get+欄位名()擷取欄位值,如在頁面中$tasksObject-getId();
至於如何確定擷取的是哪個表則是通過路由類設定該動作路由時確定的,如下例確定的是vote_question表

class opVotePluginFrontendRouteCollection extends sfRouteCollection
{
public function __construct(array $options)
{
parent::__construct($options);
$this->routes = array(
'vote_edit' => new sfDoctrineRoute(
'/vote/edit/:id',
array('module' => 'vote', 'action' => 'edit'),
array('id' => '\d+', 'sf_method' => array('get')),
array('model' => 'VoteQuestion', 'type' => 'object')
),
);
}
}
?>

以上就介紹了oops jaime pas langlais openPNE常用方法分享,包括了oops jaime pas langlais方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.