Support jOOmla! Autoit!
 
最新文章模块增加断字加省略号功能 输出PDF 打印 E-mail
Author Author: Autoit | Date Date:2006-10-25 | View Count View: 17855 | Digg Count Digg: 66

 最新文章 mod 增加断字:

修改/modules/mod_latestnews.php

defined( '_VALID_MOS' ) or die( 'Restricted access' );

下面插入[确信你有这个 utf8.php]:

require_once( 'includes/utf8.php' );

然后把结尾的:

<?php echo $row->title; ?>

替换为[可以是一行,在我换行的地方有个空格就行.]:

<?php if (utf8_strlen($row->title) > 20) 
$row->title = utf8_substr( $row->title, 0, 19)."..."; 
echo $row->title; ?>

即可。

上面意思是

当字符多于20个的话。就显示为 "前19个字符 加 ..."

 

接着给断字的标题加上 完整的提示:

在下面行

 <a href="<?php echo $link; ?>" class="latestnews<?php echo $moduleclass_sfx; ?>">

最后一个结尾的  > 前面增加:

   title='<?php echo $row->title; ?>'

就ok了。

 

热门文章 mod 的修改和这个是一样的!

 

假如你复制了好多个这样的模块,在不同的地方显示,而这个字符数又不同,那么你就要在xml里定义个变量来做了。

在mod_latestnews.xml里

 <params>

改为:

 <params>
  <param name="charecount" type="text" default="20" label="charecount" description="" />

mod_latestnews.php

$nullDate  = $database->getNullDate();

下面加上

$charecount = intval( $params->get( 'charecount', 20 ) );

上面的:

<?php if (utf8_strlen($row->title) > 20)  
$row->title = utf8_substr( $row->title, 0, 19)."..."; 
echo $row->title; ?>

要替换为:

<?php if (utf8_strlen($row->title) > $charecount)  
$row->title = utf8_substr( $row->title, 0, ($charecount-1))."..."; 
echo $row->title; ?>

保存上传,单独去设置吧!


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

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

« First « 1 2 » Last »
 
让文章标题处显示的活泼些   注册用户权限相关的一些 hack