How can I customize the labels for the pager in Yii?(如何在 Yii 中自定义寻呼机的标签?)
问题描述
我是 Yii 的新手.我想实现自定义分页.我想更改寻呼机的外观.如何更改寻呼机链接的标签?
I am new to Yii. I want to implement custom pagination. I want to change the appearance of the pager. How do I change the labels of the pager's links?
我希望链接看起来像这样:
I want the links to appear like so:
<< < 1 2 3 4 > >>
而不是它们的默认外观,如下所示:
instead of their default appearance, which is like this:
[first] [previous] 1 2 3 4 [next] [last]
我使用 CListView 来显示数据,我已经这样设置了:
I am using CListView to display the data, which I have set up like this:
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $categoryProjects,
'itemView' => '_itemDetailsView',
'ajaxUpdate'=>false,
));
谁能告诉我如何开始?我看过一些帖子,但无法获得正确的信息.
Can anyone please tell me how do I start with it? I've seen some posts but unable to get right information.
提前致谢.
推荐答案
你需要设置CListView 的 pager 属性.默认情况下,这是一个 CLinkPager;您不需要更改它(此组件已满足您的需求),但您需要对其进行配置:
You need to set the pager property of the CListView. By default, this is a CLinkPager; you don't need to change that (this component has your needs covered), but you need to configure it:
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $categoryProjects,
'itemView' => '_itemDetailsView',
'ajaxUpdate' => false,
'pager' => array(
'class' => 'CLinkPager',
'firstPageLabel' => '<<',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
'lastPageLabel' => '>>',
),
));
更新:如果您想将上述自定义配置融入"到您应用程序中的所有列表视图中,您必须创建一个新的 CustomListView 组件,该组件来自 CustomListView代码>CListView.所以你需要这个类:
Update: If you want to "bake in" the above custom configuration to all list views in your application, you have to create a new CustomListView component deriving from CListView. So you need this class:
Yii::import('zii.widgets.CListView');
class CustomListView extends CListView {
public function init() {
parent::init();
$this->pager = array(
'class' => 'CLinkPager',
'firstPageLabel' => '<<',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
'lastPageLabel' => '>>',
);
}
}
包含此内容后,您可以简单地使用 CustomListView 作为列表小部件而不是 zii.widgets.CListView.
After including this, you can simply use CustomListView as your list widget instead of zii.widgets.CListView.
这篇关于如何在 Yii 中自定义寻呼机的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Yii 中自定义寻呼机的标签?
基础教程推荐
- 将变量从树枝传递给 js 2022-01-01
- php中的PDF导出 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- php中的foreach复选框POST 2021-01-01
