总结
豆包 AI 助手文章总结

typecho里themes/../index.php的pageNav,如何跟Widget_Archive的pageNav关联?

php中文网
发布: 2016-06-06 20:32:45
原创
1920人浏览过

user/themes/default文件夹里的index.php,有this->pagenav,而widget_archive里也有pagenav,当index.php里执行this->pagenav时,会执行widget_archive里的pagenav

请问,为什么会这样执行呢? 我在Widget_Archive里只看到有:

require_once $this->_themeDir . $this->_themeFile;
登录后复制
登录后复制

这样一句话。难道是require进来了,就能在前台的index.php文件里,执行后台的pageNav函数?

user/themes/default/index.php里的pageNav代码:

< "?php $this->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>"
登录后复制
登录后复制

Widget_Archive里的pageNav代码:

立即学习PHP免费学习笔记(深入)”;

/**
     * 输出分页
     *
     * @access public
     * @param string $prev 上一页文字
     * @param string $next 下一页文字
     * @param int $splitPage 分割范围
     * @param string $splitWord 分割字符
     * @param string $template 展现配置信息
     * @return void
     */
public function pageNav($prev = '&laquo;', $next = '&raquo;', $splitPage = 3, $splitWord = '...', $template = '')
    {
        if ($this->have()) {
            $hasNav = false;
            $default = array(
                'wrapTag'       =>  'ol',
                'wrapClass'     =>  'page-navigator'
            );

            if (is_string($template)) {
                parse_str($template, $config);
            } else {
                $config = $template;
            }

            $template = array_merge($default, $config);

            $total = $this->getTotal();
            $this->pluginHandle()->trigger($hasNav)->pageNav($this->_currentPage, $total, 
                $this->parameter->pageSize, $prev, $next, $splitPage, $splitWord);

           if (!$hasNav && $total > $this->parameter->pageSize) {
                $query = Typecho_Router::url($this->parameter->type .
                (false === strpos($this->parameter->type, '_page') ? '_page' : NULL),
                $this->_pageRow, $this->options->index);

                /** 使用盒状分页 */
                $nav = new Typecho_Widget_Helper_PageNavigator_Box($total, 
                    $this->_currentPage, $this->parameter->pageSize, $query);

                echo '<' . $template['wrapTag'] . (empty($template['wrapClass']) 
                    ? '' : ' class="' . $template['wrapClass'] . '"') . '>';
                $nav->render($prev, $next, $splitPage, $splitWord, $template);
                echo '</' . $template['wrapTag'] . '>';
            }
        }
登录后复制
登录后复制

回复内容:

user/themes/default文件夹里的index.php,有this->pagenav,而widget_archive里也有pagenav,当index.php里执行this->pagenav时,会执行widget_archive里的pagenav

请问,为什么会这样执行呢? 我在Widget_Archive里只看到有:

require_once $this->_themeDir . $this->_themeFile;
登录后复制
登录后复制

这样一句话。难道是require进来了,就能在前台的index.php文件里,执行后台的pageNav函数?

user/themes/default/index.php里的pageNav代码:

< "?php $this->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>"
登录后复制
登录后复制

Widget_Archive里的pageNav代码:

立即学习PHP免费学习笔记(深入)”;

/**
     * 输出分页
     *
     * @access public
     * @param string $prev 上一页文字
     * @param string $next 下一页文字
     * @param int $splitPage 分割范围
     * @param string $splitWord 分割字符
     * @param string $template 展现配置信息
     * @return void
     */
public function pageNav($prev = '&laquo;', $next = '&raquo;', $splitPage = 3, $splitWord = '...', $template = '')
    {
        if ($this->have()) {
            $hasNav = false;
            $default = array(
                'wrapTag'       =>  'ol',
                'wrapClass'     =>  'page-navigator'
            );

            if (is_string($template)) {
                parse_str($template, $config);
            } else {
                $config = $template;
            }

            $template = array_merge($default, $config);

            $total = $this->getTotal();
            $this->pluginHandle()->trigger($hasNav)->pageNav($this->_currentPage, $total, 
                $this->parameter->pageSize, $prev, $next, $splitPage, $splitWord);

           if (!$hasNav && $total > $this->parameter->pageSize) {
                $query = Typecho_Router::url($this->parameter->type .
                (false === strpos($this->parameter->type, '_page') ? '_page' : NULL),
                $this->_pageRow, $this->options->index);

                /** 使用盒状分页 */
                $nav = new Typecho_Widget_Helper_PageNavigator_Box($total, 
                    $this->_currentPage, $this->parameter->pageSize, $query);

                echo '<' . $template['wrapTag'] . (empty($template['wrapClass']) 
                    ? '' : ' class="' . $template['wrapClass'] . '"') . '>';
                $nav->render($prev, $next, $splitPage, $splitWord, $template);
                echo '</' . $template['wrapTag'] . '>';
            }
        }
登录后复制
登录后复制
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
豆包 AI 助手文章总结
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号