By19.Published on2010-02-22.
提供下侧边栏的最新留言
显示头像为主,类似代码很多,我也只是加了一个JS的提示效果~简单写下我的方法。在需要插入最新留言的地方加入:
1
| <ul id="recentcomments"> |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| <?php
global $wpdb, $comments, $comment;
$comments = $wpdb->get_results("SELECT comment_author, comment_author_email, comment_author_url, comment_ID, comment_post_ID, SUBSTRING(comment_content,1,65) AS comment_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 18");
if ($comments): foreach ($comments as $comment): $comment_author_19 = $comment->comment_author;
if ($comment_author_19 == "") {$comment_author_19 = "Anonymous";}
$order = array ("\r\n","\n","\r");
$order2 = array ("\"","\'");
$replace = '';
$tmpstr = str_replace($order2, "", str_replace($order, $replace, sprintf('%s', strip_tags($comment->comment_excerpt))));
$content = '<span class=\'recentcommentslink_author\'>' . $comment_author_19 . '</span> <span class=\'recentcommentslink_on\'>on</span> <span class=\'recentcommentslink_title\'>' . get_the_title($comment->comment_post_ID) . '</span><div class=\'recentcommentslink_excerpt\'>' . $tmpstr . '</div>';
echo '<li class="recentcomments"><div id="C_' . $comment->comment_ID . '_d" style="display:none">' . $content . '</div>' . '<a title="' . $comment_author_19 . ' on ' . get_the_title($comment->comment_post_ID) . '" id="C_' . $comment->comment_ID . '" class="recentcommentslink" href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '" >' . get_avatar($comment->comment_author_email, 40) . '</a></li>';
endforeach;
endif;
?> |
1
| <script type="text/javascript">jQuery(document).ready(function(){new tooltip_19(".recentcommentslink");})</script> |
修改DESC LIMIT 18来调整最新评论数量,或者你也可以自己写成函数调用,之后加入下面的JS和CSS就行了:
1
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script> |
1
2
3
4
5
6
7
8
9
10
11
| jQuery.noConflict();
var tooltip_19 = function(tid) {
var xOffset = 10; var yOffset = 20; var t;
jQuery("a" + tid).hover(function(e) {
var aid = jQuery(this).attr("id");
t = jQuery("#" + aid + "_d").html();
jQuery("body").append("<div id='tooltip_19'>" + t + "</div>");
jQuery("#tooltip_19").css("top", (e.pageY + yOffset) + "px").css("right", (jQuery(window).width() - e.pageX + xOffset) + "px").fadeIn("fast").show();
}, function() {jQuery("#tooltip_19").remove();});
jQuery("a" + tid).mousemove(function(e) {jQuery("#tooltip_19").css("top", (e.pageY + yOffset) + "px").css("right", (jQuery(window).width() - e.pageX + xOffset) + "px").show();});
}; |
1
2
3
4
5
6
7
| #tooltip_19{position:absolute;border:1px solid #222222;background:#FFFFFF;padding:5px;color:#222222;display:none; z-index:23;}
#recentcomments li{float: left; padding:0px;}
.recentcommentslink_author{ font-weight:bold; font-size:1.2em;}
.recentcommentslink_on { padding: 0px 5px 0px 5px; font-style:italic;}
.recentcommentslink_title { color:#666666; font-size:0.8em;}
.recentcommentslink_excerpt {clear:both; color:#333333; font-size:0.9em; width:200px; padding:10px;}
.avatar {border: 1px solid #d3d3d3; background-color: #fff;padding: 1px; margin-bottom: 2px; margin-right: 10px;} |
即右侧~可以自己调整显示框的样式,我这里加了一个简单的箭头。
By19.Published on2009-02-27.
全AJAX的SVN-WEB客户端浏览程序及WP插件
这个SVN的WEB客户端浏览程序是在网络找到的一套开源的PHP(原作者:Lukin <mylukin@gmail.com> )修改而来~主要是因为想要做一款可自由定制界面的SVN-AJAX WEB浏览器,浏览匿名用户有读取权限的SVN目录。提供两套:整站程序(演示地址:http://www.ll19.com/svn/),以及WP的插件(插件效果见下方),插件可以直接在文章中引入SVN的目录供浏览。这里浏览的是我在GOOGLE上的SVN:http://glll.googlecode.com/svn/trunk。
插件的用法,可以在文章中或者模板中引入SVN目录,比如:
1
2
3
4
| //激活插件后文章中
[wp_svn_add svn_server="http://glll.googlecode.com/svn/trunk" svn_path="/src/php/"]
//模板中
< ?php wp_svn_add("http://glll.googlecode.com/svn/trunk","/src/php/"); ?> |
插件引入两个参数,第一个是SVN的根路径,第二个是要显示SVN的路径。其中根目录不能以“/”结束。
glll – Revision 21: /src/php/
/src/php/
PS:我个人的主张是不在自己的站点激活很多的插件,这个插件为了在文章中输出SVN的地址加了一个文章的filter函数,当然这并不会对性能造成太大的影响,如果你还是觉得为了几篇文章就加一个filter函数很不值得的话可以照我的做法:首先我也没有激活这个插件,我只是在测试环境启用后把生成的HTML复制进来而已(本地生成的话域名别忘记改成自己的),HTML包括svn_19_main的这个ID的DIV和下面的JS及SPAN标签。这样也可以达到SVN的文章AJAX浏览效果。比如这段HTML代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| <div id="svn_19_main" name="svn_19_main_1">
<h2>Revision 197: /trunk/sql/</h2><ul>
<li><a class="folder" href="#/trunk/">..</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/AddPermission.sql" target="_blank">AddPermission.sql</a></li>
<li><a class="folder" href="#/trunk/sql/LK/">LK/</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/eisp_oracle_20061130.sql" target="_blank">eisp_oracle_20061130.sql</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/eisp_sqlserver_20061130.txt" target="_blank">eisp_sqlserver_20061130.txt</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/lisw.sql" target="_blank">lisw.sql</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/readme.txt" target="_blank">readme.txt</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/xiangts.sql" target="_blank">xiangts.sql</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/yangg.sql" target="_blank">yangg.sql</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/zw.sql" target="_blank">zw.sql</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/%e6%95%b0%e6%8d%ae%e7%a7%bb%e6%a4%8d%e5%bb%ba%e8%a1%a8SQL.sql" target="_blank">数据移植建表SQL.sql</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/%e6%9c%89%e7%94%a8sql.txt" target="_blank">有用sql.txt</a></li>
<li><a class="file" href="http://localhost/wwwroot/wp-content/plugins/wp_svn_browse/view.php?svn_server=http://localhost/svn/sdww/sdww&path=/trunk/sql/%e8%bd%a6%e8%be%86%e7%ae%a1%e7%90%86.sql" target="_blank">车辆管理.sql</a></li>
</ul> </div>
<script type="text/javascript">
jQuery("div[@name='svn_19_main_1'] ul li a").svn_ajax_19("svn_19_main_1","http://www.ll19.com/wwwroot/wp-content/plugins/wp_svn_browse/","http://localhost/svn/sdww/sdww");
</script>
<span style="display:none" id="nowSvnFolder_svn_19_main_1">/trunk/sql/</span> |
当然如果你觉得这样做麻烦也可以直接激活插件,文章传入[wp_svn_add svn_server="http://glll.googlecode.com/svn/trunk" svn_path="/src/php/"]就OK了~
| 这里下载插件 | 这里下载单独的WEB Client程序 |
(全文 …)