|
自定义任意分类里文章上横幅图片的显示
|
|
|
|
Author: Autoit | Date:2006-12-25 | View: 10221 | Digg: 61 |
|
上次说到 " 自定义任意菜单下横幅图片的自定义显示 ", 不过在有分类的 content 中常常会有点不够的感觉, 比如: 在一个单元里建立了N个分类. 那么按上篇文章的话, 在这N个分类里上面出现的 图片 都是一样的了.... 现在要实现的是"A分类上面出现A相关的图.[这个默认就可以做的.分类设置里自己可以加.] , 不过很多都需要这样: "这个A分类里的每篇文章上面显示A分类的相关图片, 比方说设计类, 那么在设计类的文章上面都显示一张设计类的图. " , 当然这个图还能被加上返回这个分类的首页面。 方法:/components/com_content/content.html.php 里 <?php
if ( $row->catid =="1")
echo "<div style=\"padding: 10px 0;\" align=\"center\"><img src=\"/images/stories/header/head1.gif\" ></div>";
if ( $row->catid =="13")
echo "<div style=\"padding: 10px 0;\" align=\"center\"><img src=\"/images/stories/header/head2.gif\"></div>";
if ( $row->catid =="14")
echo "<div style=\"padding: 10px 0;\" align=\"center\"><img src=\"/images/stories/header/head3.gif\" ></div>";
if ( $row->catid =="15")
echo "<div style=\"padding: 10px 0;\" align=\"center\"><img src=\"/images/stories/header/head4.gif\"></div>";
?> 上面是我实现本地网站所 hack 的。 意思是。 在一单元里有4个分类,对应 ID为 1,13,14,15 . 当分类ID为 1的时候, 文章上面显示head1的图。当然你也可以给里面图片加上链接。 如果分类多的话,可以写成这样: <?php
switch ($row->catid) {
case '1':
echo "<div style=\"padding: 10px 0;\" align=\"center\"><a href=\"/content/category/1/1/26/\"><img src=\"/images/stories/header/head1.gif\" border=\"0\"></a></div>";
break;
case '13':
echo "<div style=\"padding: 10px 0;\" align=\"center\"><a href=\"/content/category/1/13/26/\"><img src=\"/images/stories/header/head2.gif\" border=\"0\"></a></div>";
break;
case '14':
echo "<div style=\"padding: 10px 0;\" align=\"center\"><a href=\"/content/category/1/1/26/\"><img src=\"/images/stories/header/head3.gif\" border=\"0\"></a></div>";
break;
case '15':
echo "<div style=\"padding: 10px 0;\" align=\"center\"><a href=\"/content/category/1/13/26/\"><img src=\"/images/stories/header/head4.gif\" border=\"0\"></a></div>";
break;
case '16':
echo "<div style=\"padding: 10px 0;\" align=\"center\"><a href=\"/content/category/1/13/26/\"><img src=\"/images/stories/header/head5.gif\" border=\"0\"></a></div>";
break;
}
?>ok,我是加在了 450行左右的 : if ( $params->get( 'item_title' ) || $params->get( 'pdf' ) || $params->get( 'print' ) || $params->get( 'email' ) ) {
?>下面了,当然你也可以根据你的地方加。 |
|
|
将最新文章模块hack成两列输出样式[2]
|
|
|
|
Author: Autoit | Date:2006-12-23 | View: 11484 | Digg: 57 |
|
下面是效果图: 
上面是由下面改善的模块罗列在一起后实现的[模块复制]
最上行是后台可定义的一张图片,并带有 more定义的链接. 末尾的 more 是后台可定义的链接。 实现方法是依据上篇文章 “将最新文章模块hack成两列输出样式” 来完善的。 1, mod_latestnews.xml 结尾部分的 </params> 替换为: <param name="image" type="text" size="45" default="" label="top_image" description="" />
<param name="more" type="text" size="45" default="" label="more link" description="" />
</params> 2, mod_latestnews.php 里的 $nullDate = $database->getNullDate(); 替换为: $image = trim( $params->get( 'image') );
$more = trim( $params->get( 'more' ) );
$nullDate = $database->getNullDate(); 下面的 // Output
?> 替换为: // Output
if ($image != "") echo '<div style="margin-bottom:5px;"><a href="'.$more.'">
<img src="'. $image.'" border="0"></a></div>';
?> 将: <ul class="latestnews<?php echo $moduleclass_sfx; ?>"> 替换为: <table width='98%' border='0' class="latestnews<?php echo $moduleclass_sfx; ?>"
cellspacing="0" cellpadding="0"> 下面的: 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; ?>">
<a href="<?php echo $link; ?>" class="latestnews<?php echo $moduleclass_sfx; ?>">
<?php echo $row->title; ?></a>
</li>
<?php
}
?>
</ul> 替换为: if ($rowcounter%2==1) {
echo "<td width='4%' style=\"background: url(/images/gdot2.gif); background-position: center bottom; background-repeat: repeat-y;\"></td><td class=\"latestnews". $moduleclass_sfx."\" width=\"48%\" style=\"background: url(/images/gdot.gif); background-position: 2cm bottom; background-repeat: repeat-x; \" height=\"25\">";
} else {
echo "<td class=\"latestnews". $moduleclass_sfx."\" width=\"48%\" style=\"background: url(/images/gdot.gif); background-position: 2cm bottom; background-repeat: repeat-x; \" height=\"25\" >";
} ?>
<img src="/images/con_dot.jpg" align="absbottom"> <a href="<?php echo $link; ?>" class="latestnews<?php echo $moduleclass_sfx; ?>">
<?php echo $row->title; ?></a> <small>(<?php echo substr( $row->created,5,5 ); ?>)</small>
</td>
<?php
$rowcounter++;
}
if ($rowcounter%2<>0) {
for ($i = 1; $i <= (2-($rowcounter%2)); $i++) {
echo "<td width='4%' style=\"background: url(/images/gdot2.gif); background-position: center bottom; background-repeat: repeat-y;\"></td><td width='48%' style=\"background: url(/images/gdot.gif); background-position: 2cm bottom; background-repeat: repeat-x;\"><img src=\"/images/con_dot.jpg\"> <a href=\"".$more."\" class=\"latestnews". $moduleclass_sfx."\">more...</a></td>\n";
}
}
echo "</tr>\n</table>\n";
?> Ok. End By Autoit 常规设置: 1:此模块的标题不要显示, 因为要输出图片啦. 当然你模块里的图片未设置他就不会出现. 2:文章条目设置为奇数, 上面是设置9, 这样的话, more 才会显示... 3:此模块的标题显示 + 此模块的图片路径为空 + 上面设置为偶数 --》 效果等于 "将最新文章模块hack成两列输出样式" 一文的效果。 注意: 上面是针对一本地站点hack后,直接帖上来的, 未改动什么,所以里面涉及到3个小图片[/images/ 下面],一个是行的下划线, 一个是中间的竖线, 另一个是那个三角[没写在css里是因为这样好调试出效果来] .... 三个图片:    |
|
|
sef化后, 结尾增加.html 的方法
|
|
|
|
Author: Autoit | Date:2006-12-19 | View: 16513 | Digg: 71 |
|
/includes/sef.php 将: defined( '_VALID_MOS' ) or die( 'Restricted access' ); 替换为: defined( '_VALID_MOS' ) or die( 'Restricted access' );
$_SERVER['REQUEST_URI']=str_replace(".html","",$_SERVER['REQUEST_URI']); 将18行左右: $url_array = explode('/', $_SERVER['REQUEST_URI']); 替换为: $url_array = explode('/', $_SERVER['REQUEST_URI']=str_replace(".html","",$_SERVER['REQUEST_URI'])); 搜索下行代码第一个出现的地方[约在513行左右] // allows SEF without mod_rewrite 在其上面增加 if(!strcasecmp(substr($string,-1),"/"))$string=substr($string,0,-1);
if($string!="")$string.=".html"; ok. 这样,你的也就有了这个 .html 的尾巴了... 不一定适合所有的组件. 如果你刚好碰到了可能要用下面的样子来替换上面的两行: if (!eregi("com_docman",$string)){
if(!strcasecmp(substr($string,-1),"/"))$string=substr($string,0,-1);
if($string!="")$string.=".html";
}注意: 上面代码里出现的 com_docman 就是在com_docman 里不加这个尾巴.你的看着改. 其实我用的是: $string=substr($string,0,-1);
$string.=".html"; 都没加判断...因为我用的东西也不多,使用过程没发现异常... ^_^ 最近很忙, 乘今天升级之际顺便先简单写出来, 供需要的人参考. |
|
|
不装组件也让你的文章显示出关键字来--[3]
|
|
|
|
Author: Autoit | Date:2006-11-25 | View: 9623 | Digg: 72 |
|
其实只要 "不装组件也让你的文章显示出关键字来--[1]" 或 "不装组件也让你的文章显示出关键字来--[2]" 相关文章里的任一个方法都是可以显示文章的关键字[tag]的了.当然是有点点位置上的差别. [1]的文章效果是在"首页" 或"blog页面" 不会出现 tags 的. 只在看全文的时候出现.[2]的效果就是都出现.---->[我的环境问题,开始没考虑那么多.因为我现在的站上没首页内容和blog显示...] 这篇文章写的内容算是对前两篇的补充吧[shuiziliu 要求的, 俺本人没想那么多] : 效果 --> 搜索对应的标签时, 搜索结果只出现标签相同的. 方法: /mambots/search/content.searchbot.php 里63行左右 switch ($phrase) {下面增加: case 'tags':
$wheres2 = array();
$wheres2[] = "LOWER(a.metakey) LIKE LOWER('%$text%')";
$where = '(' . implode( ') OR (', $wheres2 ) . ')';
break;如果你使用的是以前前两文的效果[在这篇文章发布的时候,我已经修改了前两文的一个地方],这个时候还要改改以前修改的地方里的下面相似的一句: $link="index.php?option=com_search&searchphrase=tags&ordering=newest&searchword="; 如果你装有AkoComment的话, [2]的tags会出现的评论的下方,这个时候如果想出现在上方的话.可以把 [1], [2]两文里的都添加上! 并修正 [2] 里的 content.html.php 改的地方的: if ($links!=""){替换为: if (($links!="") && ( $params->get( 'intro_only' )) ) {这样,两个就很好的结合起来了. Ok, 这样 tags 应该算是完美了. End by Autoit. |
|
|
不装组件也让你的文章显示出关键字来--[2]
|
|
|
|
Author: Autoit | Date:2006-11-23 | View: 9961 | Digg: 54 |
|
在Blog页也能出现的方法: 放在 修改时间的位置, 所以后台把 是否显示修改时间 选是! [不想在加改什么...了,直接使用现有的用.] 如果你有用过这个是直接改 content.php 的话, 请把改的 content.php 里面的删除. 这次改的是 components/com_content/content.html.php 搜 : function ModifiedDate [大概 860行左右] 在</tr> 下面加: <?php //以下加上是为了获取tags By Autoit
$links = '';
$keys = explode( ',', $row->metakey );
foreach ($keys as $key) {
$key = trim( $key );
if ($key) {
$link="index.php?option=com_search&searchphrase=all&ordering=newest&searchword=";
$link.=rawurlencode($key);
$links.="<a href='".$link."'>".$key."</a> ";
}
}
if ($links!=""){
echo "<tr><td colspan='2' align='right' class='tags'>";
echo "Tags: ".$links;
echo "</td></tr>";
}
//获取tags结束 By Autoit
?>如果你不显示 "修改时间" 的话,把 function ModifiedDate 段里的: <tr>
<td colspan="2" align="left" class="modifydate">
<?php echo _LAST_UPDATED; ?> ( <?php echo $mod_date; ?> )
</td>
</tr>替换为:
<!--<tr>
<td colspan="2" align="left" class="modifydate">
<?php echo _LAST_UPDATED; ?> ( <?php echo $mod_date; ?> )
</td>
</tr>--> Ok. End By Autoit. |
|
|