运营狗 - dedecms https://blog.seo135.com/tag/dedecms/ zh-CN Sat, 15 Jun 2019 14:46:00 +0800 Sat, 15 Jun 2019 14:46:00 +0800 织梦DedeCMS图集调用添加图片数字编号自增 https://blog.seo135.com/555.html https://blog.seo135.com/555.html Sat, 15 Jun 2019 14:46:00 +0800 运营狗 织梦DedeCMS图集调用标签为 {dede:field name='imgurls' alt='图片输出区'}
[field:imgsrc/]
{/dede:field}
,其中 [field:global.autoindex/] 和其他递增标签在图集中调用是没有作用,下面是实现图集图片数字递增的方法。

前台效果

织梦DedeCMS

前端代码

图集调用添加图片数字编号自增

实现方法

打开 /include/taglib/productimagelist.lib.php 文件 找到

$ctp->LoadSource($innerText);

在它下面加入

$GLOBALS['autoindex'] = 0;

继续找到

$revalue .= $ctp->GetResult();

在它下面加入

$GLOBALS['autoindex']++;

完成。

]]>
1 https://blog.seo135.com/555.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦DedeCMS顶级栏目和子栏目保存目录相同默认页不同的设置方法 https://blog.seo135.com/549.html https://blog.seo135.com/549.html Tue, 11 Jun 2019 16:34:53 +0800 运营狗 织梦程序中,当你想把顶级栏目和子栏目所有的静态文件都存在在同一个目录时,我们需要设置子栏目默认页的名称不同来区分,不然生成时会被最后生成的栏目覆盖index.html

例如,顶级栏目,我们不用修改它的【默认页的名称】index.html

织梦

所有子栏目,文件保存目录都跟顶级栏目一样,但是默认页的名称不一样,例如

织梦

最后还需要改一个文件

虽然我们可以设置系统-核心设置里的【栏目网址使用目录名(不显示默认页,即是 /a/abc/ 形式)】为【否】,但是后面会自带index.html尾巴,我们可以改一下程序文件来完美实现

打开 /include/helpers/channelunit.helper.php 找到 大概在251行

if($cfg_typedir_df=='N' || $isdefault==0) $reurl = $typedir.'/'.$defaultname;

改成

if($defaultname != 'index.html' || $cfg_typedir_df=='N' || $isdefault==0) $reurl = $typedir.'/'.$defaultname;

保存,重新生成全站就可以了。

最终效果

最终效果

]]>
0 https://blog.seo135.com/549.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦DedeCMS增加栏目推荐功能 https://blog.seo135.com/542.html https://blog.seo135.com/542.html Wed, 05 Jun 2019 17:31:00 +0800 运营狗 最终效果

后台效果
织梦DedeCMS增加栏目推荐功能

前台效果
织梦DedeCMS增加栏目推荐功能

1、添加字段 (后台-系统-SQL命令行工具-执行)

ALTER TABLE `#@__arctype` ADD `ishot` CHAR( 255 ) NOT NULL DEFAULT '';

2.修改/dede/templets/catalog_add.htm

找到

<tr>
  <td width="150" class='bline' height="26" style="padding-left:10px;">是否隐藏栏目:</td>
  <td class='bline'>
   <input type='radio' name='ishidden' value='0' class='np' checked="checked" />
   显示 &nbsp;
   <input type='radio' name='ishidden' value='1' class='np' />
   隐藏
 </td>
</tr>

在下面增加

<tr>
 <td class="bline" style="padding-left:10px;" width="150" height="26">是否推荐栏目:</td>
 <td class="bline">
  <input name="ishot" value="1" class="np" type="radio" />
  是 &nbsp;
  <input name="ishot" value="0" class="np" type="radio"  checked='1' />
  否
 </td>
</tr>

3.修改/dede/catalog_add.php

找到(一共有三处,注意别改少了)

ishidden,

后面增加

ishot,

找到

'$namerule2','0','0',

修改成

'$namerule2','0','0','0',

4.修改/dede/templets/catalog_edit.htm

找到

<tr>
<td width="150" class='bline' height="26" style="padding-left:10px;">是否隐藏栏目:</td>
  <td class='bline'>
   <input type='radio' name='ishidden' value='0' class='np'<?php if($myrow['ishidden']=="0") echo " checked='1' ";?>/>
   显示 &nbsp;
   <input type='radio' name='ishidden' value='1' class='np'<?php if($myrow['ishidden']=="1") echo " checked='1' ";?>/>
   隐藏
</td>
</tr>

下面增加

<tr>
 <td class="bline" style="padding-left:10px;" width="150" height="26">是否推荐栏目:</td>
 <td class="bline">
  <input name="ishot" value="1" class="np" type="radio" <?php if($myrow['ishot']=="1") echo " checked='1' ";?>>
  是 &nbsp;
  <input name="ishot" value="0" class="np" type="radio" <?php if($myrow['ishot']=="0") echo " checked='1' ";?>/>
  否
 </td>
</tr>

5.修改/dede/catalog_edit.php

找到如下代码(注意一共有两处)

ishidden='$ishidden',

下面增加

ishot='$ishot',

调用方法

dede:channel调用

{dede:channel row='6' typeid='3' type='son'}
  <li [field:ishot runphp="yes"]
    if(@me==1) @me="class='hot'";else @me="";
    [/field:ishot]>
    <a href="[field:typelink/]">[field:typename/]</a>
  </li>
{/dede:channel}

dede:channelartlist调用

<li {dede:field.ishot runphp="yes"}
    if(@me==1) @me="class='hot'";else @me="";
      {/dede:field.ishot}>
     <a href="{dede:field.typeurl/}">{dede:field name='typename'/}</a>
</li>

完成。

]]>
0 https://blog.seo135.com/542.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦DedeCMS搜索页显示自定义字段的方法 https://blog.seo135.com/535.html https://blog.seo135.com/535.html Tue, 04 Jun 2019 18:53:00 +0800 运营狗 DEDECMS程序搜索页结果显示自定义字段的解决办法,修改前请备份

1、打开 /include/extend.func.php 文件,在最底部添加以下代码

function Search_addfields($id,$result){
global $dsql;
//dede_addonsoft 请修改为你自己的模型表名称 
$row4 = $dsql->GetOne("SELECT * FROM `dede_addonsoft` where aid='$id'");
$name=$row4[$result];
return $name;
}

织梦DedeCMS搜索页显示自定义字段的方法

2、然后在arc.searchview.class.php里找到

//处理一些特殊字段

在下边添加下边这句代码:

// zd 改为你的自定义字段名称
$row["zd"]=Search_addfields($row["id"],"zd");

如果有多个,就添加多行。

完成。

]]>
0 https://blog.seo135.com/535.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦DedeCMS channelartlist标签当前栏目高亮 https://blog.seo135.com/533.html https://blog.seo135.com/533.html Tue, 04 Jun 2019 17:41:00 +0800 运营狗 channelartlist标签完美支持currentstyle属性,实现自动加载当前栏目CSS样式,可以用来标识当前栏目位置的CSS,解决方法如下:

打开文件 include/taglib/channelartlist.lib.php

找到

$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);

在此行代码下方增加以下代码

//子栏目当前高亮 start
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['reid'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] || $typeids[$i]['id'] == GetTopid($refObj->TypeLink->TypeInfos['id']) )
{
    $pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'current';
}
else
{
    $pv->Fields['currentstyle'] = '';
}
//子栏目当前高亮 start

        $pv->SetTemplet($innertext,'string');
        $artlist .= $pv->GetResult();
        $GLOBALS['itemparity'] = ($GLOBALS['itemparity']==1 ? 2 : 1);
        if($GLOBALS['itemindex']==$totalRow-1){$GLOBALS['iflast']=1;}
    }
    //注销环境变量,以防止后续调用中被使用
    $GLOBALS['envs']['typeid'] = $_sys_globals['typeid'];
    $GLOBALS['envs']['reid'] = '';
    if($cacheid !='') {
        WriteCacheBlock($cacheid, $artlist);
    }
    return $artlist;
}

调用方法

{dede:channelartlist typeid='103,8,6,4' currentstyle='current'}
    <li class='{dede:field.currentstyle/}'><a href='{dede:field name='typeurl'/}' title='{dede:field name='typename'/}'>{dede:field name='typename'/}</a></li>
{/dede:channelartlist}

PS:调用方法仅供参考,如有疑问,下方留言

]]>
0 https://blog.seo135.com/533.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦DedeCMS图集调用标签{dede:productimagelist}使用[field:title/]教程 https://blog.seo135.com/530.html https://blog.seo135.com/530.html Tue, 04 Jun 2019 11:33:00 +0800 运营狗 {dede:productimagelist}织梦图集标签给img添加alt属性时默认要调用的是注释(即:[field:text/]),可是为了节省时间和劳动力,不想给每张图片都填写注释而是想直接调用标题,也就是想用[field:title/]标签,下面是实现方法。

打开 /include/taglib/productimagelist.lib.php 文件

找到(约20行):

if(!isset($refObj->addTableRow['imgurls'])) return ;

在此代码下边添加如下代码:

$aid = $refObj->ArcID;
$row = $refObj->dsql->GetOne("SELECT title FROM `dede_archives` WHERE `id` = '$aid';");
$title = $row['title'];

找到(约41行):

$row['text'] = $ctag->GetAtt('text');

在此代码下边添加如下代码:

$row['title'] = $title;

调用代码:

[field:title/]

示例

{dede:productimagelist}
<a href="javascript:ChangePic('[field:imgsrc/]', '#bigpicimg');" title="[field:title/]" rel="facebox"><img src="[field:imgsrc/]" width="120" height="90" /></a>
{/dede:productimagelist}
]]>
0 https://blog.seo135.com/530.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦DedeCMS图集上传图片自动获取图片名称做注释 https://blog.seo135.com/591.html https://blog.seo135.com/591.html Thu, 23 May 2019 10:15:00 +0800 运营狗 织梦图集上传图片默认是要手动填写注释的,有时我们做好了产品图和图片名称,为了方便想让上传图片后自动获取图片名做注释。

实现示范

自动获取图片名称做注释

修改教程

1、打开 /dede/swfupload.php 找到,大概在137行

echo "FILEID:".$_SESSION['fileid'];

在它的上面加入

$file_snames = explode('.', $Filename);
$file_filename = $file_snames[count($file_snames)-2];
$_SESSION['file_filename'][$_SESSION['fileid']] = $file_filename;

继续找到

/************************
//删除指定ID的图片
*************************/

在它的上面加入

/************************
//生成注释
function GetThumbnail(){  }
*************************/
else if($dopost=='thumbalt')
{
    if( empty($id) )
    {
        header('HTTP/1.1 500 Internal Server Error');
        echo 'No ID';
        exit(0);
    }
    if (!is_array($_SESSION['file_filename']) || !isset($_SESSION['file_filename'][$id]))
    {
        header('HTTP/1.1 404 Not found');
        exit(0);
    }
    if($cfg_soft_lang=='utf-8') $file_filename = $_SESSION['file_filename'][$id];
    else $file_filename = iconv( 'UTF-8', 'gb2312//IGNORE' , $_SESSION['file_filename'][$id]);
    echo $file_filename;
    exit(0);
}

2、打开 /dede/album_add.php 找到

$imginfo =  !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : '';

改成

$imginfo =  !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : $_SESSION['file_filename'][$k];

3、打开 /dede/album_edit.php 找到

$imginfo =  !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : '';

改成

$imginfo =  !empty(${'picinfook'.$k}) ? ${'picinfook'.$k} : $_SESSION['file_filename'][$k];

4、打开 /dede/js/handlers.js 找到

newImgDiv.innerHTML += '<div style="margin-top:10px">注释:<input type="text" name="picinfo'+albImg+'" value="" style="width:'+iptwidth+'px;" /></div>';

改成

newImgDiv.innerHTML += '<div style="margin-top:10px">注释:<input type="text" name="picinfo'+albImg+'" value="" style="width:'+iptwidth+'px;" id="picinput'+albImg+'" /><span id="picinfo'+albImg+'" style="display:none;"></span></div>';
var picinfo = document.getElementById('picinfo'+albImg);
var picinput = document.getElementById('picinput'+albImg);
var myajax = new DedeAjax(picinfo,false,false,"","","");
myajax.SendGet2('swfupload.php?dopost=thumbalt&id='+pid);
picinput.value = picinfo.innerHTML;
DedeXHTTP = null;

完成

]]>
0 https://blog.seo135.com/591.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦DedeCMS自定义表单导出到excel https://blog.seo135.com/532.html https://blog.seo135.com/532.html Thu, 04 Apr 2019 22:04:00 +0800 运营狗 织梦DedeCMS自定义表单导出到excel

实现教程

1、/dede/templets/diy_main.htm 找到

前台预览</a>

在它的下面加入一行

| <a href="diy_list.php?action=excel&diyid={dede:field.diyid/}" target="_blank">导出表单Excel</a>

2、/dede/diy_list.php 找到

array('post', 'list', 'edit', 'check', 'delete'))

改成

array('post', 'list', 'edit', 'check', 'delete', 'excel'))

继续找到

else
{
    showmsg('未定义操作', "-1");
}

在它的上面加入

else if($action == 'excel')
{
    header("Content-type:application/vnd.ms-excel");
    header("Content-Disposition:attachment;filename={$diy->name}_".date("Y-m-d").".xls");
    $fieldlist = $diy->getFieldList();
    echo "<table><tr>";
    foreach($fieldlist as $field=>$fielddata)
    {
        echo "<th>{$fielddata[0]}</th>";
    }
    echo "<th>状态</th>";
    echo "</tr>";
    $sql = "SELECT * FROM {$diy->table} ORDER BY id DESC";
    $dsql->SetQuery($sql);
    $dsql->Execute('t');
    while($arr = $dsql->GetArray('t'))
    {
        echo "<tr>";
        foreach($fieldlist as $key => $field)
        {
            echo "<td>".$arr[$key]."</td>";
        }
        $status = $arr['ifcheck'] == 1 ? '已审核' : '未审核';
        echo "<td>".$status."</td>";
        echo "</tr>";
    }
    echo "</table>";
}

PS:导出的excel文件请用wps软件打开,office软件下好像会乱码。

]]>
0 https://blog.seo135.com/532.html#comments https://blog.seo135.com/feed/tag/dedecms/
织梦dedecms实现文章字数统计 https://blog.seo135.com/213.html https://blog.seo135.com/213.html Mon, 02 Jul 2018 17:47:00 +0800 运营狗 织梦系统默认是没有文章字数统计功能的,但最近本屌的一个范文站出现很多带XX字的搜索词(eg:报告范文5000字),就想着在标题下方加个文章字数显示,下面来看看如何实现。

找到文件夹include/helpers/中的extent.helper.php文件,把下面代码扔到文件最下方

// 统计文章字数
function strlen_gbk($str) {
    $i = 0;
    $count = 0;
    $str = Html2text($str);
    $len = strlen($str);
    while ($i < $len) {
        $chr = ord($str[$i]);
        $count++;
        $i++;
        if ($i >= $len) {
            break;
        }
        if ($chr & 0x80) {
            $chr <<= 1;
            while ($chr & 0x80) {
                $i++;
                $chr <<= 1;
            }
        }
    }
    return $count;
}

最后在文章模板中用以下代码输出

此处内容已隐藏

最后效果

织梦dedecms文章字数统计
PS:在统计字符的时候可能把空格之类的也统计进去了,字数会偏多一点,不影响使用~

]]>
35 https://blog.seo135.com/213.html#comments https://blog.seo135.com/feed/tag/dedecms/