zoukankan      html  css  js  c++  java
  • yii主题

     修改应用的配置文件(protected/config/main.php)中加入

    return array(

        ’theme’=>’basic’,

    );

    所有的视图文件必须位于views下 ,布局视图文件在views/layouts下 ,和系统视图文件在views/system下
    例如,如果我们要替换PostController的create 视图文件为classic主题下,我们将保存新的视图文件为WebRoot/themes/classic/views/post/create.php。
     当我们调用render或renderPartial显示视图,相应的view(视图)文件以及布局文件将在当前激活的主题里(themes/$themeName/views/)寻找。如果发现,这些文件将被渲染。否则,就后退到应用的视图目录下(application/views/)寻找。
     在一个主题的视图内部,我们经常需要链接其他主题的资源文件。例如,我们可能要显示一个在主题下images目录里的图像文件,

    方法为:yii: :app()->theme->baseUrl .'/images/FileName.gif'

    使用例子:

    WebRoot/

        assets

        protected/

            .htaccess

            components/

            controllers/

            models/

            views/

                layouts/

                    main.php

                site/

                    index.php

        themes/

            basic/

                views/

                    .htaccess

                    layouts/

                        main.php

                    site/

                        index.php

            fancy/

                views/

                    .htaccess

                    layouts/

                        main.php

                    site/

                        Index.php

    如果在应用配置(protected/config/main.php)中配置

    return arrray(

    'theme' => 'basic',

    )

    Basic主题将生效,意味着应用的布局将使用 目录 themes/basic/views/layouts 下的视图,
    站点的 index 视图将使用 目录 themes/basic/views/site 下的视图。若在主题中没有找到一个视图文件,
    它 将后退到目录 protected/views。


    Skins(换肤)

    使用皮肤来系统化的定制视图中的 widget 的外观,

    为了使用皮肤特征,我们首先需要改变应用配置(protected/config/main.php)来安装 widgetFactory 组件,配置如下:

    return array(

        ’components’=>array(

            ’widgetFactory’=>array(

                ’class’=>’CWidgetFactory’,

            ),

        ),

    );

    属于同一个 widget 类的皮肤被存储在 一个名字和此 widget 类相同的单个PHP脚本文件中,默认地,所有这些皮肤文件存储在目录 protected/views/skins中,当使用主题时, Yii 将也在主题的视图目录中的 skins 目录寻找皮肤。(例如WebRoot/themes/$themeName/views/skins)

    例如,我们创建一个名为 CLinkPager.php 的文件到目录 protected/views/skins(或者themes/$themeName/views/skins), 它的内容如下,

    <?php

    return array(

        'default' => array(//

            'nextPageLabel' => '上一页',

            'prevPageLabel' => '下一页',

           'maxButtonCount' => 10,

           //'header' => '',

           'cssFile' => Yii::app()->theme->baseUrl.'/css/pager.css'

        ),

        'classic' => array(

           'nextPageLabel' => '上一页classic',

            'prevPageLabel' => '下一页classic',

           //'header' => '',

           'maxButtonCount' => 5,

            'cssFile' => Yii::app()->theme->baseUrl.'/css/pager1.css',

        ),

    );

    ?>

     

    在上面,我们 CLinkPager widget 创建了两个皮肤: default 和 classic。 前者是我们不明确指定 CLinkPager 的 skin属性时使用的皮肤,
    而后者是其skin属性被指定为 classic 时使用的皮肤。例如,在下面的视图代码中,
    第一个 pager 将使用 default 皮肤而第二个使用 classic 皮肤:


    <?php $this->widget('zii.widgets.CListView', array(

        'summaryText' => '显示 {start}-{end} of {count} result(s).',

        'pager' => array(),

        'dataProvider'=>$dataProvider,

        'itemView'=>'_view',

    )); ?>

     

    <?php $this->widget('zii.widgets.CListView', array(

        'summaryText' => '显示 {start}-{end} of {count} result(s).',

        'pager' => array('skin'=>'classic'),

        'dataProvider'=>$dataProvider,

        'itemView'=>'_view',

    )); ?>












  • 相关阅读:
    算法的力量
    图文细说11种计算机图标符号的历史
    位图像素的颜色
    位图像素的颜色
    大数处理之三(除法)
    大数处理之三(除法)
    大数处理之二(幂运算)
    大数处理之二(幂运算)
    浮点数(double)的优势
    大数处理之一(加法和乘法)
  • 原文地址:https://www.cnblogs.com/ldms/p/8317681.html
Copyright © 2011-2022 走看看