日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Yii視圖層(View)初步

 朱啟發(fā) 2014-11-12
一、關(guān)于breadcrumbs 
1,給breadcrumbs加超鏈接 
Php代碼  收藏代碼
  1. $this->breadcrumbs=array(  
  2.     'Message'=>array('message/index'),   
  3.     'HelloWorld',  
  4. );  

2,給breadcrumbs修改首頁為中文 
我目前采用的是在config/main.php中設(shè)置為zh_ch,但還有另外一種解決辦法, 
Php代碼  收藏代碼
  1. <?php  
  2. $this->widget('zii.widgets.CBreadcrumbs'array(  
  3.    'homeLink'=>CHtml::link('首頁',Yii::app()->homeUrl),     
  4.     //這里可以修改HOME,變成中文  
  5.     'links'=>$this->breadcrumbs,  
  6. )); ?><!-- breadcrumbs -->  

3,博客breadcrumbs使用 
1,現(xiàn)在../components/controller.php中添加 
Php代碼  收藏代碼
  1. public $breadcrumbs=array();  

2,在再../views/layouts/main.php 
Php代碼  收藏代碼
  1. <?php if(isset($this->breadcrumbs)):?>  
  2.         <?php $this->widget('zii.widgets.CBreadcrumbs'array('links'=>$this->breadcrumbs,)); ?>  
  3.     <?php endif?>  

3,在具體頁面中 
Php代碼  收藏代碼
  1. $this->breadcrumbs=array(  
  2.     'xx列表'=>array('index'),  
  3.     $model->workerName,  
  4. );  


二、關(guān)于createUrl和CHtml::link參數(shù)設(shè)置的區(qū)別 
前者將多個參數(shù)放進一個數(shù)組中,后者直接向后累計添加(不放進數(shù)組) 
1,createUrl應用 
Html代碼  收藏代碼
  1. <a href="<?php echo $this->createUrl('news/view',array('id'=>$companyNew->id,'news_type'=>$companyNew->news_type)) ?>" title="<?php echo $companyNew->title ?>">  

批注:在MVC中,可以使用$this->createUrl();在../components/xx.php中使用Yii::app()->createUrl(); 

2,CHtml::link應用 
Html代碼  收藏代碼
  1. <?php echo CHtml::link(CHtml::encode($data->title), array('view', 'id'=>$data->id,'news_type'=>$data->news_type)); ?>  
  2.   
  3. //例如:  
  4. <?php echo CHtml::link('Link Text', array('controller/action','param1'=>'value1'));?>  
  5. html輸出是<a href="index.php?r=controller/action&param1=value1">Link Text</a>  
  6.   
  7. //多參數(shù)  
  8. <?php echo CHtml::link('Link Text', array('controller/action','param1'=>'value1','param2'=>'value2'));?>  
  9. html輸出是<a href="index.php?r=controller/action&param1=value1&param2=value2">Link Text</a>  
  10.   
  11. //額外參數(shù):  
  12. <?php echo CHtml::link('Link Text', array('controller/action','param1'=>'value1'), array('target'=>'_blank'));?>  
  13. html輸出是<a target="_blank" href="index.php?r=controller/action&param1=value1">Link Text</a>  
  14.   
  15. //絕對路徑:  
  16. <?php echo CHtml::link('Link Text', array('/controller/action'));?>  
  17.   
  18. //指定模塊下的路徑  
  19. <?php echo CHtml::link('Link Text', array('/module-id/controller/action'));?>  
  20.   
  21. //無效鏈接:  
  22. <?php echo CHtml::link('Link Text', array('href'=>'javascript:void(0)'));?>  
  23. <a href="javascript:void(0)">Link Text</a>  



三、CHtml::linkButton 
<?php echo CHtml::linkButton('LinkName', array('submit'=>array('controller/action','param'=>'value1'), 'confirm'=>"Are you sure?",));?> 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多