Typecho输出独立页面列表

Typecho输出独立页面列表

2023年08月09日 作者头像 作者头像 泽泽社长 编辑

评论

0 Count

输出所有独立页面的超链接,一般用于显示在菜单上,或者网站底部

<?php \Widget\Contents\Page\Rows::alloc()->to($pages); ?>
  <?php while ($pages->next()): ?>
        <a<?php if ($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
  <?php endwhile; ?>

其中<?php if ($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?>是判断当前页面缩略名是否等于独立页面列表中的某个独立页面,等于则对超链接追加独立的class使其样式与其他作为区别。