>  기사  >  백엔드 개발  >  typecho里themes/../index.php的pageNav,如何跟Widget_Archive的pageNav关联?

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

WBOY
WBOY원래의
2016-06-06 20:32:451670검색

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

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

<code>require_once $this->_themeDir . $this->_themeFile;
</code>

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

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

<code>pageNav('« 前一页', '后一页 »'); ?>"
</code>

Widget_Archive里的pageNav代码:

<code>/**
     * 输出分页
     *
     * @access public
     * @param string $prev 上一页文字
     * @param string $next 下一页文字
     * @param int $splitPage 分割范围
     * @param string $splitWord 分割字符
     * @param string $template 展现配置信息
     * @return void
     */
public function pageNav($prev = '«', $next = '»', $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 '';
                $nav->render($prev, $next, $splitPage, $splitWord, $template);
                echo '' . $template['wrapTag'] . '>';
            }
        }
</code>

回复内容:

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

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

<code>require_once $this->_themeDir . $this->_themeFile;
</code>

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

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

<code>pageNav('« 前一页', '后一页 »'); ?>"
</code>

Widget_Archive里的pageNav代码:

<code>/**
     * 输出分页
     *
     * @access public
     * @param string $prev 上一页文字
     * @param string $next 下一页文字
     * @param int $splitPage 分割范围
     * @param string $splitWord 分割字符
     * @param string $template 展现配置信息
     * @return void
     */
public function pageNav($prev = '«', $next = '»', $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 '';
                $nav->render($prev, $next, $splitPage, $splitWord, $template);
                echo '' . $template['wrapTag'] . '>';
            }
        }
</code>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.