V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
flyingsky
V2EX  ›  PHP

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

  •  
  •   flyingsky · 2015-06-25 15:28:54 +08:00 · 2610 次点击
    这是一个创建于 3228 天前的主题,其中的信息可能已经有所发展或是发生改变。
    php新手,最近在看typecho的源码,遇到一个很困惑的问题:
    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('« 前一页', '后一页 »'); ?>"

    Widget_Archive里的pageNav代码:
    /**
    * 输出分页
    *
    * @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 '<' . $template['wrapTag'] . (empty($template['wrapClass'])
    ? '' : ' class="' . $template['wrapClass'] . '"') . '>';
    $nav->render($prev, $next, $splitPage, $splitWord, $template);
    echo '</' . $template['wrapTag'] . '>';
    }
    }
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2797 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 06:41 · PVG 14:41 · LAX 23:41 · JFK 02:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.