typecho的handsome主题微调
2024-11-06 16:55:51 # 技术笔记

用国typecho和wordpress之后,个人还是比较中意typecho这个,handsome主题相对全面,所以就选择使用它了。但是总有一些自己小瑕疵需要自己去调整,比如归档页面的文章目录等等,handsome版本: 9.2.1(个人是php菜鸡,没学过,一边百度一边改。)

取消归档页面的文章目录

找到主题文件下面的sidebar.php然后打开编辑,搜索到<!--非文章页面-->这个之后,然后会看到<?php echo PostContent::returnTOC($this->is('page'),false) ?>这个代码,这个就是非文章界面的文章目录显示。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!--非文章页面-->
<?php if (!($this->is('post'))) : ?>
<section id="tag_cloud" class="widget widget_tag_cloud wrapper-md padder-v-none clear">
<h5 class="widget-title m-t-none"><?php _me("标签云") ?></h5>
<div class="tags l-h-2x panel wrapper-sm padder-v-ssm">
<?php Typecho_Widget::widget('Widget_Metas_Tag_Cloud','ignoreZeroCount=1&limit=30')->to($tags); ?>
<?php if($tags->have()): ?>
<?php while ($tags->next()): ?>
<a href="<?php $tags->permalink();?>" class="label badge"><?php $tags->name(); ?></a>
<?php endwhile; ?>
<?php endif; ?>
</div>
</section>

<!--<?php echo PostContent::returnTOC($this->is('page'),false) ?>-->
<?php
// 获取当前页面的路径
$currentUrlPath = parse_url($this->permalink, PHP_URL_PATH);
// 判断是否为页面,且 URL 中不包含 "archive"
if ($this->is('page') && substr($currentUrlPath, -12) !== 'archive.html' ) {
echo PostContent::returnTOC(true, false);
}
?>


<?php else: ?>

如果你想对具体方法进行操作,可以找到libs/content/PostContent.php 这个就是相应的右侧边栏的一些用到的方法。

去除掉友情链接的内页链接

友情链接嘛,就是links,那我们就在主题文件夹下搜索links

1
2
3
4
5
6
7
8
<ul class="nav no-padder b-b">
<li class="nav-item active"><a class="nav-link" href data-toggle="tab" data-target="#my-info"><?php
_me("申请友链")
?></a></li>
<!--<li class="nav-item"><a class="nav-link" href data-toggle="tab" data-target="#tab_2"><?php _me("内页链接") ?></a></li>-->
<li class="nav-item"><a class="nav-link" href data-toggle="tab" data-target="#tab_4"><?php _me("全站链接") ?></a></li>
<li class="nav-item"><a class="nav-link" href data-toggle="tab" data-target="#tab_3"><?php _me("推荐链接") ?></a></li>
</ul>

这里就是对链接的显示,注释掉你不喜欢的就可以了。

注释完毕后,如果你有强迫症的话,可以想我一样进行接下来的更改。针对后台管理的友情链接的操作。找到插件里面的handsome插件,找到Plugin.php这个文件,里面有个form函数,就是他,你若找到的话可以看到该函数下面有一部分的代码。注释掉你不喜欢的就可以了。

1
2
3
4
5
6
$sort = new Typecho_Widget_Helper_Form_Element_Select('sort', array(
'ten' => '全站链接,首页左侧边栏显示',
// 'one' => '内页链接,在独立页面中显示(需要新建独立页面<a href="https://handsome2.ihewro.com/#/plugin" target="_blank">友情链接</a>)',
'good' => '推荐链接,在独立页面中显示',
'others' => '失效链接,不置输出,标注暂时失效的友链'
), 'ten', _t('链接输出位置*'), '选择友情链接输出的位置');

左侧边栏导航 配置

打开主题的后台,可以参考本博客的配置进行修改,左侧边栏的图标用的是feather图标,点击链接跳转查看,https://feathericons.com/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
[
{
"name": "云盘",
"feather": "cloud",
"link": "https://alist.ittoolman.com/",
"target": "_blank"
},
{
"name": "图床",
"feather": "inbox",
"link": "https://img.ittoolman.com/",
"target": "_blank"
},
{
"name": "相册",
"feather": "image",
"link": "https://blog.ittoolman.com/index.php/category/image/",
"target": "_self"
},
{
"name": "分类",
"feather": "layout",
"sub": [
{
"name": "随笔",
"feather": "edit",
"target": "_self",
"link": "https://blog.ittoolman.com/index.php/category/sui-bi/"
},
{
"name": "技术笔记",
"feather": "monitor",
"target": "_self",
"link": "https://blog.ittoolman.com/index.php/category/ji-shu-bi-ji/"
},
{
"name": "文章收藏",
"feather": "scissors",
"target": "_self",
"link": "https://blog.ittoolman.com/index.php/category/wen-zhang/"
}
]
},
{
"name": "归档",
"feather": "archive",
"link": "https://blog.ittoolman.com/index.php/archive.html",
"target": "_self"
},
{
"name": "时光机",
"feather": "clock",
"link": "https://blog.ittoolman.com/index.php/cross.html",
"target": "_self"
},
{
"name": "友人帐",
"feather": "users",
"link": "https://blog.ittoolman.com/index.php/links.html",
"target": "_self"
},
{
"name": "关于我",
"feather": "coffee",
"link": "https://blog.ittoolman.com/index.php/start-page.html",
"target": "_self"
}
]