吉他谱大全
记录

安装——开发模式——开启会员——附件类型——邮箱设置——关闭水印——去附件链接1——增加删除变量——增加栏目——url设置——搜索时间——文档模型增加字段——清除无效图片代码2——相关TAG调用3——面包屑4——修改标题、摘要 长度

 

 

 

 

1,

织梦dedecms调用自定义字段“附件”下载去除table

当我们在系统内容模型中添加附件类型字段时,前台需要用{biz:field name='字段名'/}来调用。

例如我在后台发布一篇文章,上传一个zip的附件,字段的时间内容是:'/uploads/soft/100602/1-100602212355.zip',而前台则显示下面的内容。

<table width='300'>
     <tr>
         <td height='30' width='20'><a href='/uploads/soft/100602/1-100602212355.zip' target='_blank'><img src='~cfg_phpurl~/img/addon.gif' border='0' align='center'></a></td>
         <td><a href='/uploads/soft/100602/1-100602212355.zip' target='_blank'><u>/uploads/soft/100602/1-100602212355.zip</u></a></td>
     </tr>
</table>

而我只想调用'/uploads/soft/100602/1-100602212355.zip',怎么办?

下面就是去除多余table代码的修改方法:

1、打开文件 /theme/system/channel_addon.htm

2、把里面的代码全都删掉,只写~link~即可。

 

 

2,

第一步、 找到后台路径中的 /templets/content_batch_up.htm

 <label><input type="radio" value="delerrpic" name="action" />清空错误的图片</label>

第二步、找到 /admin/content_batchup_action.php

在最后一个大括号后增加
else if($action == 'delerrpic')
{
      $file_a=array();
       function rFile($p){
             global $file_a;
             $handle=opendir($p);
             $dir_a=array();
             while ($file = readdir($handle)) {
                    if($file!="." && $file!=".."){
                          $tmp=$p."/".$file;
                          if(is_dir($tmp)){
                                 $dir_a[count($dir_a)]=$tmp;
                          }elseif(is_file($tmp)){
                                 $file_a[count($file_a)]=$tmp;
                          }
                    }
             }
             closedir($handle);
             foreach($dir_a as $v){
                    rFile($v);
             }
      }
      rFile("../uploads/allimg");//调用,要遍历的目录
      foreach($file_a as $v){
             $temp=substr($v,2);

             $tempimg = $dsql->GetOne("SELECT * FROM #@__archives AS b ,#@__addonarticle AS a  WHERE a.aid=b.id and (a.body like '%".$temp."%' OR b.litpic like '%".$temp."%'); ");
             if(!is_array($tempimg)){
                    if(substr($v, -8, 4)!="_lit" && substr($v, -10, 5)!="index"){
                          if(file_exists($v)){
                                 unlink($v);
                          }
                    }
             }

      }
      $dsql->Close();
      ShowMsg("成功清除错误图片!","");
      exit();
}

 

 

3,新建一个文件名称为liketags.lib.php,存放在/system/taglib/目录下。该文件代码如下:

<?php
if(!defined('DEDEINC')) exit('Request Error!');
function lib_liketags(&$ctag,&$refObj)
{
    global $dsql,$envs;
    
    //属性处理
    $attlist="row|12,titlelen|30,infolen|250,col|1,tablewidth|100,typeid|0,byabs|0,imgwidth|120,imgheight|90,flag|";
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $revalue = '';
    
    if(empty($tablewidth)) $tablewidth = 100;
    if(empty($col)) $col = 1;
    $colWidth = ceil(100/$col);
    $tablewidth = $tablewidth."%";
    $colWidth = $colWidth."%";
$orwheres = '';
if($flag != '') {
$flags = explode(',', $flag);
for($i=0; isset($flags[$i]); $i++) $orwheres .= " AND FIND_IN_SET('{$flags[$i]}', arc.flag)>0 ";
}
 
    $ids = array();
    $tids = array();
    
    if(!empty($refObj->Fields['tags'])) {
        $keyword = $refObj->Fields['tags'];
    }
    else {
        $keyword = ( !empty($refObj->Fields['keywords']) ? $refObj->Fields['keywords'] : '' );
    }
    
    $typeid = ( !empty($typeid) ? $typeid : 0 );
    if(empty($typeid))
    {
        if(!empty($refObj->Typelink->TypeInfos['reid'])) {
             $typeid = $refObj->Typelink->TypeInfos['reid'];
        }
        else {
             if(!empty($refObj->Fields['typeid'])) $typeid = $refObj->Fields['typeid'];
        }
    }
    
    if( !empty($typeid) && !preg_match('#,#', $typeid) ) {
        $typeid = GetSonIds($typeid);
    }
    
if(!empty($refObj->Fields['tags']) && $eregtype != 'keyword' ) 
{
$tags = explode(',', addslashes($refObj->Fields['tags']));
$getsql = " tag like '".join("' OR tag like '", $tags)."' ";
$dsql->Execute('me', "Select * From `biz_tagindex` where $getsql ");
while($arow = $dsql->GetArray('me'))
{
$tids[] = $arow['id'];
}
$tid = join(',', $tids);
if($tid!='')
{
$dsql->Execute("me", "Select aid From `biz_taglist` where tid in($tid) And arcrank > -1 group by aid order by aid desc");
while($arow = $dsql->GetArray("me"))
{
$ids[] = $arow['aid'];
$arcid =  $refObj->Fields['aid'];
}
} 
}
 
//获得附加表的相关信息
$addField = "";
$addJoin = "";
if(is_object($refObj->ChannelUnit))
{
$addtable  = $refObj->ChannelUnit->ChannelInfos['addtable'];
if($addtable!="")
{
$addJoin = " LEFT JOIN $addtable ON arc.id = ".$addtable.".aid ";
$addField = "";
$fields = explode(",",$refObj->ChannelUnit->ChannelInfos['listfields']);
foreach($fields as $k=>$v)
{
$nfields[$v] = $k;
}
foreach($refObj->ChannelUnit->ChannelFields as $k=>$arr)
{
if(isset($nfields[$k]))
{
if(!empty($arr['rename']))
{
$addField .= ",".$addtable.".".$k." as ".$arr['rename'];
}
else
{
$addField .= ",".$addtable.".".$k;
}
}
}
}
}
 
if($eregtype == 'tag' && count($ids) == 0 )
{
return;
}
else
{
if(count($ids) > 0)
{
if(!empty($typeid))
{
$typeid = " And arc.typeid in($typeid) And arc.id<>$arcid ";
}
$idsStr = join(',', $ids);
$query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, 
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath $addField 
from `biz_archives` arc left join `biz_arctype` tp on arc.typeid=tp.id $addJoin 
where arc.arcrank>-1 and arc.id in($idsStr) $typeid order by arc.id desc limit 0, $row";
}
else
{
$limitRow = $row - count($ids);
$keyword = '';
if(!empty($refObj->Fields['keywords']))
{
$keywords = explode(',' , trim($refObj->Fields['keywords']));
$keyword = '';
$n = 1;
foreach($keywords as $k)
{
if($n > 3)  break;
 
if(trim($k)=='') continue;
else $k = addslashes($k);
 
$keyword .= ($keyword=='' ? " CONCAT(arc.keywords,' ',arc.title) like '%$k%' " : " OR CONCAT(arc.keywords,' ',arc.title) like '%$k%' ");
$n++;
}
} 
$arcid = (!empty($refObj->Fields['id']) ? $refObj->Fields['aid'] : 0);
if( empty($arcid) || $byabs==0 )
{
$orderquery = " order by arc.id desc ";
}
else
{
$orderquery = " order by ABS(arc.id - ".$arcid.") ";
}
if($keyword != '')
{
if(!empty($typeid))
{
$typeid = " And arc.typeid in($typeid) And arc.id<>$arcid ";
}
$query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, 
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath $addField 
from `biz_archives` arc left join `biz_arctype` tp on arc.typeid=tp.id $addJoin 
where arc.arcrank>-1 and ($keyword)  $typeid $orderquery limit 0, $row";
}
else
{
if(!empty($typeid))
{
$typeid = " arc.typeid in($typeid) And arc.id<>$arcid ";
}
$query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, 
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath $addField 
from `biz_archives` arc left join `biz_arctype` tp on arc.typeid=tp.id $addJoin 
where arc.arcrank>-1 and  $typeid $orderquery limit 0, $row";
}
}
}
 
    $innertext = trim( $ctag->GetInnerText() );
    if($innertext=='') $innertext = GetSysTemplets('part_arclist.htm');
    $dsql->SetQuery($query);
    $dsql->Execute('al');
    $artlist = '';
    if($col > 1){
        $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>";
    }
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace('field', '[', ']');
    $dtp2->LoadString($innertext);
    $GLOBALS['autoindex'] = 0;
    $line = $row;
    for($i=0; $i < $line; $i++)
    {
        if($col>1) $artlist .= "<tr>";
        for($j=0; $j < $col; $j++)
        {
            if($col>1) $artlist .= "    <td width='$colWidth'>";
            if($row = $dsql->GetArray("al"))
            {
                $ids[] = $row['id'];
                //处理一些特殊字段
                $row['info'] = $row['infos'] = cn_substr($row['description'],$infolen);
                $row['id'] =  $row['id'];
 
                if($row['corank'] > 0 && $row['arcrank']==0)
                {
                    $row['arcrank'] = $row['corank'];
                }
 
                $row['filename'] = $row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
                $row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);
 
                $row['typeurl'] = GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],
                $row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
 
                if($row['litpic'] == '-' || $row['litpic'] == '')
                {
                    $row['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif';
                }
                if(!preg_match("#^http://#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y')
                {
                    $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
                }
                $row['picname'] = $row['litpic'];
                $row['stime'] = GetDateMK($row['pubdate']);
                $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
                $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".preg_replace("#['><]#","",$row['title'])."'>";
                $row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
                $row['fulltitle'] = $row['title'];
                $row['title'] = cn_substr($row['title'], $titlelen);
                if($row['color']!='') $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
                if(preg_match('#b#', $row['flag'])) $row['title'] = "<strong>".$row['title']."</strong>";
                $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
                $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
                $row['memberurl'] = $GLOBALS['cfg_memberurl'];
                $row['templeturl'] = $GLOBALS['cfg_templeturl'];
                
                if(is_array($dtp2->CTags))
                {
                    foreach($dtp2->CTags as $k=>$ctag)
                    {
                        if($ctag->GetName()=='array') {
                            $dtp2->Assign($k,$row);
                        }
                        else {
                            if(isset($row[$ctag->GetName()])) $dtp2->Assign($k,$row[$ctag->GetName()]);
                            else $dtp2->Assign($k,'');
                        }
                    }
                    $GLOBALS['autoindex']++;
                }
 
                $artlist .= $dtp2->GetResult();
            }
            //if hasRow
            else
            {
                $artlist .= '';
            }
            if($col>1) $artlist .= "    </td>";
        }
        //Loop Col
        if($col>1) $i += $col - 1;
        if($col>1) $artlist .= "    </tr>";
    }
    //loop line
    if($col>1) $artlist .= "    </table>";
    $dsql->FreeResult("al");
    return $artlist;
}

  调用代码

{dede:liketags row='3' titlelen='250' eregtype='tag'}
<tr>
<td style="padding-left: 10px;"><a href="[field:arcurl/]" target="_blank">[field:title/]</a></td>
<td>[field:id function=GetTags(@me)/]</td>
<td><a href="[field:arcurl/]" target="_blank">在线预览</a></td>
</tr>
{/dede:liketags}

  

4,搜索<li class='breadcrumb-item'>**</li>去掉 

 

posted on 2023-08-28 13:53  dedebiz使用记录  阅读(41)  评论(0编辑  收藏  举报
吉他谱大全