|
将最新文章模块hack成两列输出样式
|
|
|
|
Author: Autoit | Date:2006-11-23 | View: 14801 | Digg: 57 |
|
就是下图 latestnews 模块的效果: 
修改文件: modules/mod_latestnews.php 将133 行的: <ul class="latestnews<?php echo $moduleclass_sfx; ?>"> 替换为: <table width='100%' border='0' class="latestnews<?php echo $moduleclass_sfx; ?>"> 下面的: foreach ( $rows as $row ) {替换为: echo "<tr>\n";
$rowcounter = 0;
foreach ( $rows as $row ) {
if (($rowcounter%2==0) AND ($rowcounter<>0)) echo "</tr>\n<tr>\n";在这段结尾部分的: <li class="latestnews<?php echo $moduleclass_sfx; ?>"> 替换为: <td class="latestnews<?php echo $moduleclass_sfx; ?>" width="50%"> 下面的: </li>
<?php
}
?>
</ul> 替换为: </td>
<?php
$rowcounter++;
}
if ($rowcounter%2<>0) {
for ($i = 1; $i <= (2-($rowcounter%2)); $i++) {
echo " <td width='50%'></td>\n";
}
}
echo "</tr>\n</table>\n";
?>Ok. End By Autoit |
|
|
将单元内容列表 hack 成两列显示
|
|
|
|
Author: Autoit | Date:2006-11-23 | View: 10486 | Digg: 55 |
|
修改文件: components/com_content/content.html.php function showCategories 段,约 122行: <ul> 替换为: <table width='100%' border='0' cellspacing='1' cellpadding='4' class="category"> 下面行的<?php下面增加: echo "<tr>\n";
$rowcounter = 0; 将 if ( $catid != $row->id ) {替换为: // if ( $catid != $row->id ) { 并在他下行增加: if (($rowcounter%2==0) AND ($rowcounter<>0)) echo "</tr>\n<tr>\n"; 在下面的 <li> 替换为: <td> 在下面的 </li> 替换为: </td> 紧接的下面到结尾部分: <?php
}
}
?>
</ul>
<?php
} 替换为: <?php
// }
$rowcounter++;
}
if ($rowcounter%2<>0) {
for ($i = 1; $i <= (2-($rowcounter%2)); $i++) {
echo " <td width='50%'></td>\n";
}
}
echo "</tr>\n</table>\n"; // by autoit end +++++++++++++++++++++++++++++++
}Ok, End, by Autoit. |
|
|
自定义任意菜单下横幅图片的自定义显示
|
|
|
|
Author: Autoit | Date:2006-11-21 | View: 9549 | Digg: 58 |
|
最常见的是"到对应菜单"后, 出现一个关于这个菜单里的横幅。 好像很传统的站都是这样。。。 在joomla里比较简单的实现方法是[这个方法可以定义任意页面任意的自定义图, 只要这个页有 Itemid ;-) , Joomla应该都有的,因为所有 mod 都是靠 Itemid 来"运作"的.]: 在你模板的 </head> 前面增加 <?PHP
$image1 = array(1); //array 后面的数字就是你链接里的Itemid的值,支持多个,用英文逗号分开
$image2 = array(2);
$image3 = array(3);
// $image4 = array(4,5,6);
// $image5 = array(7,8);
// ...
$header="head.jpg"; //默认
if (in_array($Itemid, $image1)) $header="head1.jpg"; //在链接是Itemid的值的时候出现对应的图片出现
if (in_array($Itemid, $image2)) $header="head2.jpg";
if (in_array($Itemid, $image3)) $header="head3.jpg";
// if (in_array($Itemid, $image3)) $header="head4.jpg";
// if (in_array($Itemid, $image3)) $header="head05.jpg";
//...
?> 在你模板要出现这个图片的地方,插入下面这句就 ok 了。 <?PHP echo ("<img src=".$mosConfig_live_site."/templates/".$cur_template."/images/".$header.">")?>只帖上面代码是不行的。 主要是看你站的链接来取你的 Itemid 的值, 然后还要你做好你需要的图片[图片就放模板的images下吧]! 当然,在我使用中常这样: header的默认清空,在需要的地方在显示,不需要的地方就不显示了。 $header=""; //默认 <?PHP
if ($header !="")
echo ("<div style=\"padding: 10px;\" align=\"center\"><img src=".$mosConfig_live_site."/images/header/".$header."></div>")
?> |
|
|
让文章标题处显示的活泼些 [续] Vote's hack
|
|
|
|
Author: Autoit | Date:2006-11-16 | View: 30070 | Digg: 322 |
|
效果就是当前本站文章标题的效果: 在标题前面出现一个可以进行投票的顶 "Digg" ! 将 content.html.php 489行左右的 : if ( !$params->get( 'intro_only' ) ) {
$results = $_MAMBOTS->trigger( 'onAfterDisplayTitle', array( &$row, &$params, $page ) );
echo trim( implode( "\n", $results ) );
}
$results = $_MAMBOTS->trigger( 'onBeforeDisplayContent', array( &$row, &$params, $page ) );
echo trim( implode( "\n", $results ) );移动到: // displays Item Title 上行的 <?php 的下面. 将 /mambots/content/mosvote.php 替换为下面内容. <?php
/**
* @version $Id: mosvote.php 85 2005-09-15 23:12:03Z eddieajau $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
$_MAMBOTS->registerFunction( 'onBeforeDisplayContent', 'botVoting' );
function botVoting( &$row, &$params, $page=0 ) {
global $Itemid;
$id = $row->id;
$option = 'com_content';
$task = mosGetParam( $_REQUEST, 'task', '' );
$html = '';
$url = @$_SERVER['REQUEST_URI'];
$url = ampReplace( $url );
if (!$params->get( 'intro_only' ) && $task != "blogsection") {
$html .= '<td><form method="post" action="' . sefRelToAbs( 'index.php' ) . '">';
$html .= '<input src="./images/up.gif" class="button1" type="image" name="submit_vote" ';
$html .= 'alt="'. _RATE_BUTTON .'" />';
$html .= '<input type="radio" alt="vote 1 star" name="user_rating" value="1" ';
$html .= 'checked="checked" style="display:none"/>';
$html .= '<input type="hidden" name="task" value="vote" />';
$html .= '<input type="hidden" name="pop" value="0" />';
$html .= '<input type="hidden" name="option" value="com_content" />';
$html .= '<input type="hidden" name="Itemid" value="'. $Itemid .'" />';
$html .= '<input type="hidden" name="cid" value="'. $id .'" />';
$html .= '<input type="hidden" name="url" value="'. $url .'" />';
$html .= '</form></td>';
}
return $html;
}
?>保存个小图片 up.gif 放你你的 images目录下. 至于在标题下面和上一篇一样要显示出来顶的次数, 可以 在上次修改的地方: View: <?php echo $row->hits; ?> 后面增加: | <img src="./images/vote.gif" align="top" alt="Digg"/> Digg:
<?php echo intval( $row->rating_count ); ?> 就ok了. 当然, 要使用这个,你的投票 bot 是要发布的!  |
|
|
扩充big5_func的Gb互转utf8函数
|
|
|
|
Author: Autoit | Date:2006-11-09 | View: 10015 | Digg: 59 |
|
joomla.org.tw的版本里的 big5_func 里没有 gb <->utf8 的互转, 在没有iconv与 mb_convert的情况下使用起来就很别脚了[gb<->big5<->utf8]. 方法: 在includes/下面的 big5_func.default.php 结尾 ?> 前面增加: /******************************
//UTF-8 转GB编码
*******************************/
function utf82gb($utfstr)
{
global $UC2GBTABLE;
$okstr = "";
if(trim($utfstr)=="") return $utfstr;
if(empty($UC2GBTABLE)){
$filename = dirname(__FILE__)."/gb2312-utf8.table";
$fp = fopen($filename,"r");
while($l = fgets($fp,15))
{ $UC2GBTABLE[hexdec(substr($l, 7, 6))] = hexdec(substr($l, 0, 6));}
fclose($fp);
}
$okstr = "";
$ulen = strlen($utfstr);
for($i=0;$i<$ulen;$i++)
{
$c = $utfstr[$i];
$cb = decbin(ord($utfstr[$i]));
if(strlen($cb)==8){
$csize = strpos(decbin(ord($cb)),"0");
for($j=0;$j < $csize;$j++){
$i++; $c .= $utfstr[$i];
}
$c = utf82u($c);
if(isset($UC2GBTABLE[$c])){
$c = dechex($UC2GBTABLE[$c]+0x8080);
$okstr .= chr(hexdec($c[0].$c[1])).chr(hexdec($c[2].$c[3]));
}
else
{ $okstr .= "&#".$c.";";}
}
else $okstr .= $c;
}
$okstr = trim($okstr);
return $okstr;
}
/*******************************
//GB转UTF-8编码
*******************************/
function gb2utf8($gbstr) {
global $CODETABLE;
if(trim($gbstr)=="") return $gbstr;
if(empty($CODETABLE)){
$filename = dirname(__FILE__)."/gb2312-utf8.table";
$fp = fopen($filename,"r");
while ($l = fgets($fp,15))
{ $CODETABLE[hexdec(substr($l, 0, 6))] = substr($l, 7, 6); }
fclose($fp);
}
$ret = "";
$utf8 = "";
while ($gbstr) {
if (ord(substr($gbstr, 0, 1)) > 0x80) {
$thisW = substr($gbstr, 0, 2);
$gbstr = substr($gbstr, 2, strlen($gbstr));
$utf8 = "";
@$utf8 = u2utf8(hexdec($CODETABLE[hexdec(bin2hex($thisW)) - 0x8080]));
if($utf8!=""){
for ($i = 0;$i < strlen($utf8);$i += 3)
$ret .= chr(substr($utf8, $i, 3));
}
}
else
{
$ret .= substr($gbstr, 0, 1);
$gbstr = substr($gbstr, 1, strlen($gbstr));
}
}
return $ret;
}保存上传. 然后将gb2312-utf8.table也上传到当然目录. 那么在需要的地方就可以直使用 utf82gb() 与gb2utf8()来进行 gb 与utf8之间的转换了. Ps: 以前有写的一个 mod_baidump3search [在当前页面上[utf8编码格式]选中要在baidu mp3里搜索的字后点击当前图片就可以直接在 mp3.baidu.com [gb2312编码格式]里搜索.]里也有用到的一个 utf转gb的函数, 那个是用 JS 来实现的. 如果需要,可以下载参考. |
|
|