• 首页
  • 相册
  • 归档
  • 微语
  • 友链
  • 关于
  • 搜索
  • 夜间模式
    ©2023-2026  吹牛部落 Theme by OneBlog
    搜索
    标签
    # Typecho # css # php # 域名 # html # 截图 # 魔兽世界 # JavaScript
  • 首页>
  • 默认>
  • 正文
  • typecho常用代码记录

    2024年10月27日 2.4 k 阅读 1409 字

    最近改typecho特别痛苦,我虽然学过php,那也是十几年前了,现在脑袋空空,看不懂了,只好把要用的记录下来,以备不时之需

    Typecho调用分类目录的位置添加以下代码

    <?php $this->widget('Widget_Archive@index', 'pageSize=6&type=category', 'slug=缩略码')
    ->parse('<li><a href="{permalink}">{title}</a></li>'); ?>

    调用自定义字段

    <?php $this->fields->fieldName ?>
    <img  class="tubiao"src="<?php Helper::options()->themeUrl('img/linju.svg'); ?>" alt="邻居">
    

    读者墙

     <?php
        $period = time() - 999592000; // 999592000秒
        $counts = Typecho_Db::get()->fetchAll(Typecho_Db::get()
        ->select('COUNT(author) AS cnt','author', 'url', 'mail')
        ->from('table.comments')
        ->where('created > ?', $period )
        ->where('status = ?', 'approved')
        ->where('type = ?', 'comment')
        ->where('authorId = ?', '0')
        ->group('author')
        ->order('cnt', Typecho_Db::SORT_DESC)
        ->limit(25)
        );
        $mostactive = '';
        $avatar_path = 'http://www.gravatar.com/avatar/';
        foreach ($counts as $count) {
          $avatar = $avatar_path . md5(strtolower($count['mail'])) . '.jpg';
          $c_url = $count['url']; if ( !$c_url ) $c_url = Helper::options()->siteUrl;
          $mostactive .= "<a href='" . $c_url . "' title='" . $count['author'] . " (参与" . $count['cnt'] . "次互动)' target='_blank'><img src='" . $avatar . "' alt='" . $count['author'] . "的头像' class='avatar' width='32' height='32' /></a>\n";
        }
        echo $mostactive; ?>
    本文著作权归作者 [ 吹牛部落 ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    Typecho
    — END —
    首页相册归档微语友链关于
    Copyright©2023-2026  All Rights Reserved.  Load:0.010 s
    新ICP备2024015104号-2
    Theme by OneBlog V3.7.0
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。