Support jOOmla! Autoit!
 
改造mod_latestnews的输出样式之一 输出PDF 打印 E-mail
Author Author: Autoit | Date Date:2006-06-27 | View Count View: 10036 | Digg Count Digg: 59

改造mod_latestnews使其输出可以显示内容中以 { mosimage }的第一张图片,效果为,文章的标题上面是一张内容里的第一张图片.

打开mod_latestnews.xml

在<params>的下一行加上:

<param name="imagewidth" type="text" default="" label="image width" description="image width" />

mod_latestnews.php
在$access  = !$mainframe->getCfg( 'shownoauth' );下面增加:

$imageWidth = intval($params->get('imageWidth', 0)) ;

找到

 default:
 //Content Items only
  $query = "SELECT a.id, a.title, a.sectionid, a.catid"

在末尾中的引号前增加:

, a.images

变成:

 default:
 //Content Items only
  $query = "SELECT a.id, a.title, a.sectionid, a.catid, a.images"

将:

 $link = sefRelToAbs( 'index.php?option=com_content&amp;task=view&amp;id='. $row->id . $Itemid );
 ?>
 <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>

替换成:

 $link = sefRelToAbs( 'index.php?option=com_content&amp;task=view&amp;id='. $row->id . $Itemid );
 if ($row->images)
 {
 $width = ($imagewidth> 0) ? ' width="'.$imagewidth.'"' : '' ;
 $image = explode("|", $row->images) ;
 echo '<li><a href="'. $link .'">';
 echo '<img src="'.$mosConfig_live_site.'/images/stories/'.$image[0].'"
 echo ' alt="'.$image[2].'" border="0" '.$width.' />';
 echo '<br />'. $row->title .'</a></li>';
 }
 else
 echo '<li><a href="'. $link .'">'. $row->title .'</a></li>';
 }
 echo '</ul>';
?>  

就可以了。为了不影响本来功能,我们可以另存为一个模块,将mod_latesnews.php另存为:mod_lastenewspic.php;mod_latesnews.xml另存为:mod_lastenewspic.xml,然后更改xml文件里的下面三项即可:

1.<name>Latest News</name>

改为

<name>Latest News Pic</name>

 

2.<filename module="mod_latestnews">mod_latestnews.php</filename>

改为:

<filename module="mod_latestnewspic">mod_latestnewspic.php</filename>

3.删除 

<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="type" type="list" default="0" label="Module Mode" description="...">
   <option value="1">Content Items only</option>
   <option value="2">Static Content only</option>
   <option value="3">Both</option>
  </param>

你也可以直接点这里下载我做好的,并且去处了用不到的代码...


Permanent URL: http://www.autoit.cn/index.php/content/view/45/25.html

Shares: Google书签 Yahoo书签 雅虎收藏夹 365Key网摘 新浪ViVi 百度收藏 天极网摘 diglog 和讯网摘 POCO网摘 YouNote网摘 博拉网 天下图摘 spurl blogmarks BlinkList reddit digg Del.icio.us   |  Tags: 图片  mod  

 
在线joomla网站的常用升级方法   将评分投票bot改造成现在流行用的 “顶”