Modify Templates |
出自LifeType 中文文件计画
(增加MyShare。) |
|||
(6个中途的修订版本没有显示。) | |||
第1行: | 第1行: | ||
- | |||
== 编辑文章 与 管理迴响的连结 == | == 编辑文章 与 管理迴响的连结 == | ||
编辑文章或管理迴响时,通常必须登入到管理介面,如果是旧文章就很麻烦了。在文章中加入连结,方便编辑与管理。 | 编辑文章或管理迴响时,通常必须登入到管理介面,如果是旧文章就很麻烦了。在文章中加入连结,方便编辑与管理。 | ||
第17行: | 第16行: | ||
</smarty> | </smarty> | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/461 阿驾零零壹 © 学习笔记]。 |
第29行: | 第28行: | ||
</smarty> | </smarty> | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/1160 阿驾零零壹 © 学习笔记]。 |
第58行: | 第57行: | ||
</smarty> | </smarty> | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/260 阿驾零零壹 © 学习笔记]。 |
第114行: | 第113行: | ||
</smarty> | </smarty> | ||
- | 原文有最新文章、最新迴响、分类、连结等的语法,因为太长,所以需要完整语法请参考 [http:// | + | 原文有最新文章、最新迴响、分类、连结等的语法,因为太长,所以需要完整语法请参考 [http://twntwn.info/blog/ajer001/archives/1144 阿驾零零壹 © 学习笔记]。 |
第131行: | 第130行: | ||
+<a href="http://www.hemidemi.com/user_bookmark/new?title={$post->getTopic()}&url={$url->postPermalink($post)}" target="_blank" title="Add To Your HEMiDEMi" >HEMiDEMi</a> | +<a href="http://www.hemidemi.com/user_bookmark/new?title={$post->getTopic()}&url={$url->postPermalink($post)}" target="_blank" title="Add To Your HEMiDEMi" >HEMiDEMi</a> | ||
+<a href="http://technorati.com/faves?add={$url->postPermalink($post)}" target="_blank" title="Add To Your Technorati Favorites" >Technorati</a> | +<a href="http://technorati.com/faves?add={$url->postPermalink($post)}" target="_blank" title="Add To Your Technorati Favorites" >Technorati</a> | ||
+ | +<a href="http://myshare.url.com.tw/index.php?func=newurl&url={$url->postPermalink($post)}&desc={$post->getTopic()}" target="_blank" title="Add To Your MyShare" >MyShare</a> | ||
</smarty> | </smarty> | ||
第137行: | 第137行: | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/1143 阿驾零零壹 © 学习笔记]。 |
- | + | ||
== 变更字体大小的JavaScript == | == 变更字体大小的JavaScript == | ||
第163行: | 第162行: | ||
</smarty> | </smarty> | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/1075 阿驾零零壹 © 学习笔记]。 |
第187行: | 第186行: | ||
</smarty> | </smarty> | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/199 阿驾零零壹 © 学习笔记]。 |
第202行: | 第201行: | ||
</smarty> | </smarty> | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/222 阿驾零零壹 © 学习笔记]。 |
第212行: | 第211行: | ||
<smarty> | <smarty> | ||
{assign var=blogOwner value=$blog->getOwnerInfo()} | {assign var=blogOwner value=$blog->getOwnerInfo()} | ||
+ | {if $blogOwner->getfullName()==""} | ||
+ | Blogger:{$blogOwner->getUsername()}<br/> | ||
+ | {else} | ||
Blogger:{$blogOwner->getfullName()}<br/> | Blogger:{$blogOwner->getfullName()}<br/> | ||
+ | {/if} | ||
{if $blogOwner->hasPicture()} | {if $blogOwner->hasPicture()} | ||
{assign var=picture value=$blogOwner->getPicture()} | {assign var=picture value=$blogOwner->getPicture()} | ||
<img src="{$url->resourcePreviewLink($picture)}" title="{$blogOwner->getUsername()}" /><br> | <img src="{$url->resourcePreviewLink($picture)}" title="{$blogOwner->getUsername()}" /><br> | ||
{/if} | {/if} | ||
+ | {if $blogOwner->getfullName()!=""} | ||
About:{$blogOwner->getAboutMyself()} | About:{$blogOwner->getAboutMyself()} | ||
+ | {/if} | ||
</smarty> | </smarty> | ||
- | 原文发表在 [http:// | + | 原文发表在 [http://twntwn.info/blog/ajer001/archives/221 阿驾零零壹 © 学习笔记]。 |
+ | |||
+ | |||
+ | == 解决 连结过长 无法自动换行 的问题 == | ||
+ | 这个问题通常会出现在 Summary 或是 sidebar 上面,据说出问题的都是 Firefox,XD。 | ||
+ | |||
+ | *修改办法: | ||
+ | :将你要修改的地方,利如: | ||
+ | <smarty> | ||
+ | {$comment->getText()} | ||
+ | 或 | ||
+ | {$post->getText()} | ||
+ | </smarty> | ||
+ | :在这个里面加上 '''|regex_replace:"/http:[^ ]+/":" [link] "''',例如: | ||
+ | <smarty> | ||
+ | {$comment->getText()|strip_tags|truncate:100:"..."|regex_replace:"/http:[^ ]+/":" [link] "} | ||
+ | 或 | ||
+ | {$post->getText()|strip_tags|truncate:100:"..."|regex_replace:"/http:[^ ]+/":" [link] "} | ||
+ | </smarty> | ||
+ | :如此一来就会用 [link] 连结,来取代原本的网址了。 | ||
+ | |||
+ | 原文发表在 [http://blog.nlhs.tyc.edu.tw/post/2/53 lss实验室]。 | ||
+ | |||
+ | == 要如何加入 JavaScript 到模版中才不会出问题 == | ||
+ | |||
+ | 在模版的语法中,'''{''' 与 '''}''' 是保留字,所以不能使用。如果你的 JavaScript 中包含这两个字元,那么当然就会出错。解决方式如下: | ||
+ | |||
+ | <php> | ||
+ | {literal} | ||
+ | 你的 JavaScript 程式 | ||
+ | {/literal} | ||
+ | </php> | ||
+ | |||
+ | 这样就可以了。LifeType 的模版引擎就会把这一段文字当成纯文字来看待。 |
当前修订版本
目录 |
编辑文章 与 管理迴响的连结
编辑文章或管理迴响时,通常必须登入到管理介面,如果是旧文章就很麻烦了。在文章中加入连结,方便编辑与管理。
- 使用方法:
- 修改模板,将下面语法放到适当位置即可。
- 管理前,请先登入管理区。
- 修改文章:
<a href="{$url->getUrl("/admin.php")}?op=blogSelect&blogId={$blog->getId()}&action=editPost&postId={$post->getId()}" target="_blank">修改文章</a>
- 管理迴响:
<a href="{$url->getUrl("/admin.php")}?op=blogSelect&blogId={$blog->getId()}&action=editComments&articleId={$post->getId()}" target="_blank">管理迴响</a>
原文发表在 阿驾零零壹 © 学习笔记。
发表迴响时 显示预设标题
目前的模板,都是没有标题,而通常访客也都不会填写,所以加上预设会变成「Re:文章标题」的语法。这样从 Comment RSS、Sidebar 看也会知道是回覆哪一篇文章。
- 修改办法:
- 编辑「commentform.template」,找到标题的位置,没有就自己增加。加上「value="Re:{$post->getTopic()}"」,例如:
<input id="subject" name="commentTopic" value="Re:{$post->getTopic()}" >
原文发表在 阿驾零零壹 © 学习笔记。
秘密文章
外挂程式中,有个 秘密文章,不过因为是外挂的关系,在文章列表、RSS等等许多地方,都会露馅。所以提供一下补强的办法。
- Mark 提供的版本:
没有密码要显示的东西 有密码要显示的东西
- 来源不详:
有密码要显示的东西 没有密码要显示的东西 其中,要注意 foreach 的变数。
原文发表在 阿驾零零壹 © 学习笔记。
让文章 连结 分类 等列表可收折
当文章、分类、连结等越来越多后,会发现列表「乐乐长」,这时候就要可以收纳一下。
- 说明:
- 1. 已经顺便加上了秘密文章的判断。
- 2. 对 Firefox 和 IE 都确定没有问题。
- 3. expandIt 语法由 Mark 提供,以下各用法修改自 Reic。
- 使用方法:
- 将语法贴到适当位置即可。
- 最新文章:
<!-- 最新文章 --> <script type="text/javascript"> </script> <!-- 下一行 加上标题语法 --> <a href="javascript:expandIt(document.getElementById('recentpost'))">最新文章</a> <ul id="recentpost" name="recentpost" style="display: none;"> <li><a title="Secert Post, Sorry" href="{$url->postLink($post)}">{$post->getTopic()}</a></li> <li><a title="{$post->getText()|truncate:150:"..."|strip_tags|escape}" href="{$url->postLink($post)}">{$post->getTopic()}</a></li> </ul> <!-- 在此放入结尾语法 -->
- 连结列表:
<!-- 连结 --> <script type="text/javascript"> </script> <!-- 在此放入标题语法 --> <b><a href="javascript:expandIt(document.getElementById('lnk{$smarty.foreach.linkcategory.iteration}'))"> {$linkcategory->getName()} </a></b><br /> <ul id="lnk{$smarty.foreach.linkcategory.iteration}" name="lnk{$smarty.foreach.linkcategory.iteration}" style="display: none;"> <li><a href="{$link->getUrl()}" title="{$link->getDescription()}">{$link->getName()}</a></li> </ul> <!-- 在此放入结尾语法 -->
原文有最新文章、最新迴响、分类、连结等的语法,因为太长,所以需要完整语法请参考 阿驾零零壹 © 学习笔记。
收藏文章的连结
目前网路上提供的文章连结收藏、分享的服务很多,当你写了一篇好文章的时候,也应该方便一下读者们,让他们可以方便的收藏文章。
- 说明:
- 目前有 Delicious、HEMiDEMi、Furl、Technorati,会陆续增加,或参考后面增加连结说明。
- 使用方法
- 将语法贴到文章适当位置即可。
+<a href="http://del.icio.us/login/?url={$url->postPermalink($post)}&title={$post->getTopic()}" title="Add To Your Del.icio.us" target="_blank">Del.icio.us</a> +<a href="http://www.furl.net/storeIt.jsp?p=1&t={$post->getTopic()}&u={$url->postPermalink($post)}" title="Add To Your Furl" target="_blank">Furl</a> +<a href="http://www.hemidemi.com/user_bookmark/new?title={$post->getTopic()}&url={$url->postPermalink($post)}" target="_blank" title="Add To Your HEMiDEMi" >HEMiDEMi</a> +<a href="http://technorati.com/faves?add={$url->postPermalink($post)}" target="_blank" title="Add To Your Technorati Favorites" >Technorati</a> +<a href="http://myshare.url.com.tw/index.php?func=newurl&url={$url->postPermalink($post)}&desc={$post->getTopic()}" target="_blank" title="Add To Your MyShare" >MyShare</a>
- 增加连结:
- 分析他们的连结,并且搭配 {$url->postPermalink($post)} 取得文章连结、{$post->getTopic()} 取得文章标题。
原文发表在 阿驾零零壹 © 学习笔记。
变更字体大小的JavaScript
由于每个人习惯的字体大小不同,而且阅读的时候字体大一点真的会比较舒服,利用这个语法,就可以自行放大缩小字体。
- 使用教学:
1. 编辑「header.template」,将下面语法放入<head></head>之间。
{literal}<script language="javascript" type="text/javascript"> function doZoom(size){ document.getElementById('content').style.fontSize=size+'px'} </script>{/literal} P.S. 其中,content 请改成你希望放大区域的 CSS id。
2. 将下面语法放入适当位置。
<a href="javascript:doZoom(20)">放大</a> <a href="javascript:doZoom(16)">正常</a> <a href="javascript:doZoom(12)">缩小</a> P.S. 括号内的数字代表字体大小,可自行修改。
原文发表在 阿驾零零壹 © 学习笔记。
修改每月汇整为下拉式选单
随着你的Blog使用时间越来越久,就会看到旁边的每月汇整越来越长,这时候能够收藏起来当然最好。
- 使用方法:
- 使用下面语法替换,并且加上适当的区块语法。
{literal}<script language="javascript" type="text/javascript"> function MM_jumpMenu(targ,selObj,restore){ //v3.0 }</script>{/literal} <!-- 加入区块标题语法 --> <select name="menu_menu" onChange="MM_jumpMenu('parent',this,0)"> <option>每月汇整</option> <option value="{$archivelink->getUrl()}">{$archivelink->getName()} [{$archivelink->getNumArticles()}]</option> </select> <!-- 加入区块结尾语法 -->
原文发表在 阿驾零零壹 © 学习笔记。
显示 Blog 访客人数等统计资讯
管理介面中,有个显示阅读总数、文章总数、迴响总数、引用总数的地方。我们将这个拿到模板中来显示。
- 使用方法:
- 将下面语法,你需要的项目,放到模板适当位置即可。
阅读总数:{$blog->getViewedTotal()} 文章总数:{$blog->getTotalPosts()} 迴响总数:{$blog->getTotalComments()} 引用总数:{$blog->getTotalTrackbacks()}
原文发表在 阿驾零零壹 © 学习笔记。
显示作者资料
管理介面中,有个「使用者设定」,你可以在里面设定照片、自我介绍等等。下面提供您显示的办法。
- 使用方法:
- 将下面的语法,放到你想要显示的位置,并加上适当的区块语法。
Blogger:{$blogOwner->getUsername()}<br/> Blogger:{$blogOwner->getfullName()}<br/> <img src="{$url->resourcePreviewLink($picture)}" title="{$blogOwner->getUsername()}" /><br> About:{$blogOwner->getAboutMyself()}
原文发表在 阿驾零零壹 © 学习笔记。
解决 连结过长 无法自动换行 的问题
这个问题通常会出现在 Summary 或是 sidebar 上面,据说出问题的都是 Firefox,XD。
- 修改办法:
- 将你要修改的地方,利如:
{$comment->getText()} 或 {$post->getText()}
- 在这个里面加上 |regex_replace:"/http:[^ ]+/":" [link] ",例如:
{$comment->getText()|strip_tags|truncate:100:"..."|regex_replace:"/http:[^ ]+/":" [link] "} 或 {$post->getText()|strip_tags|truncate:100:"..."|regex_replace:"/http:[^ ]+/":" [link] "}
- 如此一来就会用 [link] 连结,来取代原本的网址了。
原文发表在 lss实验室。
要如何加入 JavaScript 到模版中才不会出问题
在模版的语法中,{ 与 } 是保留字,所以不能使用。如果你的 JavaScript 中包含这两个字元,那么当然就会出错。解决方式如下:
{literal} 你的 JavaScript 程式 {/literal}
这样就可以了。LifeType 的模版引擎就会把这一段文字当成纯文字来看待。