用户名 密码 记住我 还未注册?

新浪新闻的幻灯片,代码问题!!! [技术论坛 - 主题综合]

XOOPS China 讨论区 > XOOPS Theme (主题) > 主题综合 > 新浪新闻的幻灯片,代码问题!!!

正在浏览:   1 名游客



 到底部   前一个主题   下一个主题  [无发表权] 请登录或者注册

« 1 2 (3)


回复: 新浪新闻的幻灯片,代码问题!!!
Support Team
注册日期:
2005/4/30 13:09
来自 安徽安庆
所属群组:
网站管理员
帖子: 514 | 精华: 3
等级: 20; EXP: 92
HP: 0 / 498
MP: 171 / 8228
离线
这是偶很久以前的代码,以前只贴出了theme,没想到大家都很关注.
大体部署如下:
1.在modules/article/blocks/block.php 增加如下代码

function lyveflash_article_show($options)
{
    global 
$xoopsDB,$xoopsConfig;
    
$flash_id=$options[0];
    
//array_slice($options, 1);
     
$query "SELECT art_id FROM ".art_DB_prefix("artcat")." WHERE cat_id=".$flash_id." ORDER BY art_id DESC ";                  
         if (!
$result $xoopsDB->query($query,5,0)) {
        return 
false;
               }
       
$rows = array();
       while (
$row $xoopsDB->fetchArray($result)) 
       {
       
$rows[] = $row['art_id'];
       }
   
$select="art_id";
$select.=",art_title,cat_id,art_image,art_summary";
   
$query "SELECT $select FROM " art_DB_prefix("article");
    
$query .= " WHERE art_id IN (" implode(","$rows) . ") AND art_time_publish >0 ORDER BY art_time_publish DESC";
if (!
$result $xoopsDB->query($query50)) {
        return 
false;
    }
    
$arts = array();
    
$allimgurl="";
    
$alltitlename="";
    
$LinkUrl="";
    
$i=0;
while (
$row $xoopsDB->fetchArray($result)) {
        
$_art["art_id"] = $row["art_id"];
        
$_art["art_title"] = $row["art_title"];
        
$_art["cat_id"] = $row["cat_id"];
        if (!empty(
$row["art_image"])) $imag $img=unserialize($row["art_image"]);
        if(
is_array($imag))
        {
          
$_art["art_image"]="http://www.lvye.info:8080/uploads/article/image/".$img["file"];  

//        $_art["art_image"]=art_getImageUrl($img["file"]);
        
}
        else 
$_art["art_image"]='';
        
$_art["art_summary"]=xoops_substr($row["art_summary"],0,76,"...");
        if(
$i==1)
        {
              
$allimgurl=XOOPS_URL."/uploads/article/image/".$img["file"];  
    
$alltitlename=$row["art_title"];
    
$LinkUrl=XOOPS_URL.'/modules/article/view.article.php/'.$row["art_id"].'/c'.$row["cat_id"];
        }
        else 
        {
            
//  $allimgurl="";
    //$alltitlename="";
    
$allimgurl=$allimgurl."|".XOOPS_URL."/uploads/article/image/".$img["file"];  
    
$alltitlename=$alltitlename."|".$row["art_title"];
    
$LinkUrl=$LinkUrl."|".XOOPS_URL.'/modules/article/view.article.php/'.$row["art_id"].'/c'.$row["cat_id"];
        }
        
$i=$i+1;
     
$arts[] = $_art;
     unset(
$_art);
}
$block["articles"] = $arts;
$block["faid"] = $arts[0]["art_id"];
$block["ftitle"] = $arts[0]["art_title"];
$block["artimg"]=$arts[0]["art_image"];
$block["fsummary"] = $arts[0]["art_summary"];
$block["fcatid"] = $arts[0]["cat_id"];
unset(
$arts);
$block["dirname"] = $GLOBALS["artdirname"];
$block['themeimg_url']=XOOPS_THEME_URL."/".$xoopsConfig['theme_set']."/images";
$block['allimgurl']=$allimgurl;
$block['alltitlename']=$alltitlename;
$block['LinkUrl']=$LinkUrl;
    
//var_dump($allimgurl);
    //var_dump($alltitlename);
return $block;
}


function 
lvyeflash_article_edit($options)
{
 
       
$category_handler =& xoops_getmodulehandler("category"$GLOBALS["artdirname"]);
    
$cats $category_handler->getList();
    
$isAll = empty($options[0])?true:false;
    
$options_cat array_slice($options0); // get allowed categories
    
    
$form .= art_constant("MB_CATEGORYLIST")."&nbsp;&nbsp;<select name="options[]" multiple="multiple">";
    
$form .= "<option value="0" ";
    if (
$isAll$form .= " selected="selected"";
    
$form .= ">"._ALL."</option>";
    foreach (
array_keys($cats) as $cid) {
        
$sel = ($isAll || in_array($cid$options_cat))?" selected="selected"":"";
        
$form .= "<option value="$cid" $sel>".$cats[$cid]."</option>";
    }
    
$form .= "</select><br />";
    

   return 
$form;
}


在modules/article/templates/blocks/art_block_flash.html


<style type="text/css">
.
glow{color:#ffffff;filter:glow(strength=1,color=#003366);height:0;padding:2px;}
.shadow{color:#ffffff;filter:dropShadow(offX=1,offY=1,color=#5F0000);height:0;}
.linkWhite a:link,.linkWhite a:visited {text-decoration:none;color:#015050;}
.linkWhite a:active,.linkWhite a:hover {text-decoration:none;color:#009779;}
.num01
{
    
margin-right:6px;
}
.
itemOff{background-color:#31a195;text-align:center;font-size:12px;font-family:Arial;cursor:pointer;color: White;font-weight: bold;}
.itemOn{background#ff9c00;color: White;text-align:center;font-size:12px;font-family:Arial;cursor:default;font-weight: bold;}

</style>

<
script language='javascript' type='text/javascript'>
    <!--
i=0;
/* Data begin */
var sPicArr = new Array();
<{foreach 
item=article from=$block.articles}>
sPicArr[i] = new Array("<{$article.art_image}>","<{$article.art_title}>","<{$article.art_summary}>","<{$xoops_url}>/modules/<{$block.dirname}>/view.article.php/<{$article.art_id}>/c<{$article.cat_id}>");
i=i+1;
<{/foreach}>
/* Data end */


    
function GetObj(objName){
        if(
document.getElementById){
            return eval(
'document.getElementById("' objName '")');
        }else if(
document.layers){
            return eval(
"document.layers['" objName +"']");
        }else{
            return eval(
'document.all.' objName);
        }
    }
    var 
plPic = new Image();
    var 
gIndex 0;
    function 
SlidePic(index){
        
gIndex index;
//patch by dorian 1017
        
if ('Microsoft Internet Explorer' == navigator.appName)

        {
        
document.images["slidePic"].filters.item(0).Apply();
        }
        
        
document.images["slidePic"].src sPicArr[index][0];
        
document.images["slidePic"].alt sPicArr[index][1];
        
GetObj("slidePicLink").href sPicArr[index][3];
        
GetObj("slideTitle").innerHTML sPicArr[index][1];
        
GetObj("slideDesc").innerHTML sPicArr[index][2];
        
GetObj("slideLink").innerHTML "[<a href='"+sPicArr[index][3]+"' target=_blank title='全文'>全文</a>]";

        
        if((
index+1)<sPicArr.lengthplPic.src sPicArr[index+1][0];//preload;

        
for(var i=0;i<sPicArr.length;i++){
            
GetObj("item"+i).className "itemOff";
            
GetObj("item"+i).onmouseover = function(){return false;}
            
GetObj("item"+i).onmouseout = function(){return false;}
        }
        
GetObj("item"+index).className "itemOn";
        
/*fixed by AmourGUO, 051017
        GetObj("item"+index).onmouseover = function(){
            pauseslide();
        }
        GetObj("item"+index).onmouseout = function(){
            inislide();
        }
        */
                  
if ('Microsoft Internet Explorer' == navigator.appName)
        {
        
document.images["slidePic"].filters.item(0).play();
        }
        
    }

    function 
NextPic(){
        
gIndex = ((gIndex+1)>=sPicArr.length?0:(gIndex+1));
        
SlidePic(gIndex);
    }

    function 
PrevPic(){
    
//alert(gIndex);
        
gIndex = ((gIndex-1)<0?(sPicArr.length-1):(gIndex-1));
    
//alert(gIndex);
        
SlidePic(gIndex);
        
    }
    var 
sid;
    function 
inislide()
    {
        if(
sid==nullsid setInterval('NextPic()'5000);//fixed by AmourGUO, 051017
    
}
    function 
pauseslide()
    {
        
clearInterval(sid);
        
sid null;//fixed by AmourGUO, 051017
    
}
inislide()
    
//-->
    
</script>
    <table align=center cellspacing=0 >
    <tr >
    <td width=190 valign=top bgcolor="#d2efde">
        <table width=100% cellspacing=0>
<tr>
        <td align=center  style='padding:2px 0px 5px 0px;'><a id=slidePicLink href="<{$xoops_url}>/modules/<{$block.dirname}>/view.article.php/<{$block.faid}>/c<{$block.fcatid}>" target=_blank title=''><img src="<{$block.artimg}>" alt='' name='slidePic' width="180" height="131" hspace="0" border="0" align="right"  id='slidePic' style='border:0px solid #000;filter:revealtrans(duration=2.0,transition=6);' onMouseOver="pauseslide();" onMouseOut="inislide();"></a></td>
        </tr>
      </table>
      </td>
    
    <td   bgcolor="#d2efde" >
        <table  cellspacing=0>    
<tr>
        <td  valign=top style='padding:3px 1px 2px 0px;line-height:15px;font-size: 12px;color: #024747;' onmouseover="pauseslide();" onmouseout="inislide();" width="213" height="108">
            <div id='slideTitle' class='linkWhite' style='font-weight:bold;'><{$block.ftitle}></div>
            <div class='linkWhite' style='margin-top:7px; '><span id='slideDesc'><{$block.fsummary}></span>&nbsp;&nbsp;<span id='slideLink' class=linkYellow>[<a href="<{$xoops_url}>/modules/<{$block.dirname}>/view.article.php/<{$block.faid}>/c<{$block.fcatid}>" title='全文'>全文</a>]</span></div>
        </td>
        </tr>
<tr>
        <td   height=15  width="150" align="center" bgcolor="#5cc4b4"  >
            <table   cellspacing=0 onMouseOver="pauseslide()" onMouseOut="inislide()"><!--//fixed by AmourGUO, 051017-->
            <tr>
            <td width=12><img src="<{$block.themeimg_url}>/left_arrow.jpg" width="10" height="11" alt='上一张' onClick='PrevPic();pauseslide();inislide()' style='cursor:pointer; margin-left:10px;'></td>
            <td style="font-size:12px;border: none;margin: 0 0 0 0;padding: 0 0 0 0; ">
                <script language='javascript' type='text/javascript'>
                <!--
                document.writeln("<table width=100% cellspacing=0>");
                document.writeln("<tr>");

                document.writeln("<td>&nbsp;</td>");
                document.writeln("<td id='item0' width=13 height=11 class=itemOn onClick='SlidePic(0)'>1</td>");
                for(var i=1;i<sPicArr.length;i++){

                    document.writeln("<td>&nbsp;</td>");
                    document.writeln("<td id='item"+i+"' width=13 height=11 class=itemOff onClick='SlidePic("+i+");'>"+(i+1)+"</td>");//fixed by AmourGUO, 051017
                }
                document.writeln("<td>&nbsp;</td>");
                document.writeln("</tr>");
                document.writeln("</table>");
                //-->
                </script>
            </td>
            <td width=20><img src="<{$block.themeimg_url}>/right_arrow.jpg" width="10" height="11" alt='下一张' onClick='NextPic();pauseslide();inislide()' style='cursor:pointer;'></td>
            </tr>
            </table>
          </td>
        </tr>
        
      </table>
        
    </td>
    </tr>
    </table>



在articles/xoops_version.php增加对应区块

$i
++;
$modversion["blocks"][$i]["file"] = "block.php";
$modversion["blocks"][$i]["name"] = art_constant("MI_LVYE_FLASH");
$modversion["blocks"][$i]["description"] = art_constant("MI_LVYE_FLASH_DESC");
$modversion["blocks"][$i]["show_func"] ="lyveflash_article_show";
$modversion["blocks"][$i]["options"] = "creat|5|5||0";
$modversion["blocks"][$i]["edit_func"] = "lvyeflash_article_edit";
$modversion["blocks"][$i]["template"] ="art_block_flash.html";


其中对应语言包自己加下了.

2007/4/29 10:33
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: 新浪新闻的幻灯片,代码问题!!!
中级会员
注册日期:
2007/2/21 15:58
所属群组:
注册会员
帖子: 65
等级: 6; EXP: 95
HP: 0 / 148
MP: 21 / 1670
离线
上面这个我也试了也不行 提示article/blocks/blocks.php on line 44的
$rows[] = $row['art_id'];出错

2007/4/29 11:05
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: 新浪新闻的幻灯片,代码问题!!!
Support Team
注册日期:
2005/4/30 13:09
来自 安徽安庆
所属群组:
网站管理员
帖子: 514 | 精华: 3
等级: 20; EXP: 92
HP: 0 / 498
MP: 171 / 8228
离线
我刚才在2.016(所有环境都是最新的),发现有些小问题,但应该可行的.但要注意的是后台编辑的时候,只选择某一类别.

在编辑的函数贴出来的似乎有点问题.
应该是这样:
引用:


function lvyeflash_article_edit($options)
{

$category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
$cats = $category_handler->getList();
$isAll = empty($options[0])?true:false;
$options_cat = array_slice($options, 0); // get allowed categories

$form .= art_constant("MB_CATEGORYLIST")."&nbsp;&nbsp;<select name=\"options[]\" multiple=\"multiple\">";
$form .= "<option value=\"0\" ";
if ($isAll) $form .= " selected=\"selected\"";
$form .= ">"._ALL."</option>";
foreach (array_keys($cats) as $cid) {
$sel = ($isAll || in_array($cid, $options_cat))?" selected=\"selected\"":"";
$form .= "<option value=\"$cid\" $sel>".$cats[$cid]."</option>";
}
$form .= "</select><br />";


return $form;
}









引用:

merida 写道:
上面这个我也试了也不行 提示article/blocks/blocks.php on line 44的
$rows[] = $row['art_id'];出错

2007/4/30 7:59
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: 新浪新闻的幻灯片,代码问题!!!
中级会员
注册日期:
2007/2/21 15:58
所属群组:
注册会员
帖子: 65
等级: 6; EXP: 95
HP: 0 / 148
MP: 21 / 1670
离线
多谢 解决了 是系统有问题

2007/4/30 16:03
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: 新浪新闻的幻灯片,代码问题!!!
初级会员
注册日期:
2007/2/3 9:54
所属群组:
注册会员
帖子: 21
等级: 3; EXP: 31
HP: 0 / 57
MP: 7 / 656
离线
引用:

jji33 写道:
多谢 解决了 是系统有问题


要不要下载播放器啊。

2008/7/8 10:45
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: 新浪新闻的幻灯片,代码问题!!!Support Team的
初级会员
注册日期:
2007/2/3 9:54
所属群组:
注册会员
帖子: 21
等级: 3; EXP: 31
HP: 0 / 57
MP: 7 / 656
离线
引用:

superray 写道:
非常感谢agl分享如此优秀的代码,查看此帖
绿野首页新闻幻灯的效果真的很不错,可是要想用好它还需要hack一下。本人研究了agl的代码后摸索出了一些小技巧,并做了一点改进,在此分享一下,希望能对比我还新的新手提供点帮助。
第一步:agl 原来的代码是以前版本 article 的,不适用于新版本1.0。这是本人改过后的代码,并增加了有无图片附件的判断,有图片才显示。代码:.....


好了,有个问题就是,首次调用有个空白的图片和空白的文章,
等第二轮个显示的时候就可以没什么问题了,而且可以避免没有图片的链接 。

2008/7/8 16:07
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: 新浪新闻的幻灯片,代码问题!!!
新进会员
注册日期:
2009/4/17 10:31
所属群组:
注册会员
帖子: 19
等级: 3; EXP: 9
HP: 0 / 52
MP: 6 / 258
离线
收藏

2009/4/22 20:57
_________________
just xoops it
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


回复: 新浪新闻的幻灯片,代码问题!!!Support Team的
新进会员
注册日期:
2009/4/17 10:31
所属群组:
注册会员
帖子: 19
等级: 3; EXP: 9
HP: 0 / 52
MP: 6 / 258
离线
完事后在哪更新区块啊!
xoops_data里的缓存都删除了,区块管理也没出现js幻灯片管理啊?

还有,blocks.php里要不要添加内容啊

2009/4/22 22:13
工具箱 短消息 Email PDF 书签 打印 举报 回顶部


« 1 2 (3)

  [无发表权] 请登录或者注册


不可查看帖子。
不可发帖。
不可回复。
不可编辑自己的帖子。
不可删除自己的帖子。
不可发起投票调查。
不可在投票调查中投票。
不可上传附件。
不可不经审核直接发帖。
不可使用主题类别。
不可使用HTML语法。
不可使用签名档。

[高级搜索]