typecho 模板中的这种优雅格式如何实现呢?

2017-01-02 04:06:16 +08:00
 chainmon
<div class="main">
    <?php if($this->have()):?>
        <?php while($this->next()): ?>
        <article>
            <p class="title"><a href="<?php $this->permalink() ?>" target="_blank"><?php $this->title() ?></a></p>
            <span class="date">发布于:<?php $this->date('y-m-d'); ?></span>
            <span class="author">来自<a href="<?php $this->author->permalink(); ?>"><?php $this->author(); ?></a></span>
            <div class="category"><?php $this->category(','); ?></div>
            <div class="content"><?php $this->content('阅读全文 >>'); ?></div>
        </article>
        <?php endwhile; ?>
    <?php else:?>
        <div>暂无文章</div>
    <?php endif?>
    <?php $this->pageNav('<< 上一页', '下一页 >>'); ?>
</div>

感觉这种格式可自定义化很高啊,即使小白也会用,重组性也挺高的

2771 次点击
所在节点    问与答
8 条回复
Tink
2017-01-02 04:19:16 +08:00
这不是 php ?
chainmon
2017-01-02 04:22:10 +08:00
@Tink 是类似于这样的格式 $this->have()
xfspace
2017-01-02 08:12:19 +08:00
看 Controller 的实现
Syc
2017-01-02 08:16:24 +08:00
@chainmon 熟人你好(逃
onlyhot
2017-01-02 12:05:40 +08:00
一点都不优雅
SuperMild
2017-01-02 12:10:12 +08:00
JSX 更优雅啊
Balthild
2017-01-02 12:23:40 +08:00
WordPress:

https://gist.github.com/balthild/4cc61f5ba1f34cc6817956090c74cd97

形式只是外在,套路都是一样的。
Balthild
2017-01-02 12:26:29 +08:00
补充:这种所谓的「主循环」其实类似于一个 STL 迭代器,如果你搞过 C++,理解起来会容易得多。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/331659

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX