在主题文件夹中建立 search.php 文件
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<div class="main-container">
<main>
<div>
<?php if ($this->have()): ?>
🎯 以下是<?php $this->archiveTitle(array(
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键词 <b>%s</b> 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
), '', ''); ?>
:
<hr/>
<ul class="blog-posts">
<?php while ($this->next()): ?>
<li class="post-item">
<a href="<?php $this->permalink(); ?>"><span><?php $this->title(); ?></span></a>
<time datetime="<?php $this->date("c"); ?>" itemprop="datePublished"><?php $this->date('Y/m/d'); ?></time>
</li>
<?php endwhile; ?>
</ul>
<div class="post-pagination">
<?php $this->pageNav('« 前一页', '后一页 »'); ?>
<?php $this->pageNav(" ← ", " → ", "5", "…"); ?>
</div>
<?php else: ?>
<article>
<p>🚫 <b>错误</b>:
没有找到<?php $this->archiveTitle(array(
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键词 <b>%s</b> 的文章'),
'tag' => _t('标签 %s 下的文章'),
'author' => _t('%s 发布的文章')
), '', ''); ?>
,请重新输入关键词进行搜索。
</p>
</article>
<?php endif; ?>
</main>
<?php $this->need("footer.php"); ?>
创建一个独立页面并引用模板
<?php
/**
* 搜索
*
* @package custom
*/
if (!defined("__TYPECHO_ROOT_DIR__")) {
exit();
} ?>
<?php $this->need("header.php"); ?>
<div class="main-container">
<main>
<h1></a> <?php $this->title(); ?></h1>
</br>
<hr>
<div class="search">
<form method="post">
<input type="text" name="s" class="text" placeholder="📝输入内容后请按回车键进行搜索" value= "<?php echo $this->_keywords ?>" />
</form>
</div>
<article>
<?php if ($this->content): ?>
<?php $this->content(); ?>
<?php else: ?>
<p>此页面内容尚未发布。</p>
<?php endif; ?>
</article>
</main>
<?php $this->need("footer.php"); ?>


没有回复内容