Making templates is not difficult. As long as you have written HTML and CSS, nested templates are very simple. You don't need to understand the internal structure of tags. As long as you know how to use them, the templates can be completed quickly. This article only briefly introduces how to use common tags, hoping to bring you into the world of templates.
Template information
Let’s start with the main file. When you open this file, the first thing you see is the comment:
/**
* 这是typecho系统的一套默认皮肤。你可以在<a href="http://typecho.org">typecho的官方网站</a>获得更多关于此皮肤的信息
*
* @package Typecho Default Theme
* @author typecho
* @version 1.0.0
* @link http://typecho.org
*/This is where the template information is stored, and it will be displayed on the template selection page in the background.
The first two lines are a brief introduction, and each "*" represents a paragraph.
@package represents the template name,
@author represents the author’s name,
@version is the version number of the template,
@link is the author’s website link.
Just below the comment include('header.php'), you'll also see include('sidebar.php') and include('footer.php') at the end. These statements are used to call other modules of the template. The name header means the top of the page, the sidebar is the sidebar, and the footer is the footer.
Show articles
<?php while($this->next()): ?>
<div class="post">
<h2 class="entry_title"><a href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h2>
<div class="entry_data">
Published by <a href="<?php $this->author->permalink(); ?>"><?php $this->author(); ?></a> on <?php $this->date('F j, Y'); ?> in <?php $this->category(','); ?>.
<?php $this->commentsNum('%d Comments'); ?>.
</div>
<div class="entry_text">
<?php $this->content('Continue Reading...'); ?>
</div>
</div>
<?php endwhile; ?>Enter the article loop, output the article, peel off the html code, and introduce it sentence by sentence
<?php $this->permalink() ?> 文章所在的连接
<?php $this->title() ?> 文章标题
<?php $this->author(); ?> 文章作者
<?php $this->author->permalink(); ?> 文章作者地址
<?php $this->date('F j, Y'); ?> 文章的发布日期,格式可参考PHP日期格式
<?php $this->category(','); ?> 文章所在分类
<?php $this->commentsNum('%d Comments'); ?> 文章评论数及连接
<?php $this->content('Continue Reading...'); ?> 文章内容,其中的“Continue Reading…”是显示摘要时隐藏部分的邀请连接Okay, the article display is over, don’t forget to end the loop.
Article pagination
<?php $this->pageNav(); ?>Don’t forget to add pagination after the article is output. At this point, the common content of index.php ends, so you shouldn’t be confused.