织梦cms

推荐列表 站点导航

当前位置:首页 > 建站教程 > 织梦cms >

dedecms 调用指定栏目,指定作者,指定自定义字段

来源:网络整理  作者:  发布时间:2020-12-14 04:54
百度知道里看到有人提问,帮写了一个。 模板里调用SQL: 1 2 3 4 5 6 {dede:sqlsql= selecta.id,a.title,a.writer,a.pubdate,a.typeid,b.aid...

    else

14

a.typeid=7   调用ID为7的栏目  如果不需要指定栏目ID  那么你可以把 a.typeid='7' and  删掉

29

23

b.sex=男  设置性别,也就是自定义字段。如果你的自定义字段不是sex 那么你只要把sql里的b.sex 改成你的字段,例如 name 改成b.name

                    From `{$chRow['addtable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid

32

          {/dede:sql}

    }

6

            <li>标题:<a href="[field:id function='GetOneDocUrl(@me)'/]">[field:title/]</a></li>

            <li>性别:[field:sex/]</li>

    $aid = trim(ereg_replace('[^0-9]','',$aid));

    $chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `dede_arctiny` arc left join `dede_channeltype` ch on ch.id=arc.channel where arc.id='$aid' ");

 

{dede:sql sql="select a.id,a.title,a.writer,a.pubdate,a.typeid,b.aid,b.sex from dede_archives a LEFT JOIN dede_addonarticle b on b.aid=a.id where a.typeid='7' and a.writer=~writer~ and b.sex='男' order by a.pubdate desc LIMIT 0,5"}

1

 

19

            <li>作者:[field:writer/]</li>

9

3

    {

百度知道里看到有人提问,帮写了一个。

1

10

LIMIT 0,5  设置要调用的条数,我这里写的是5条,自行修改.

5

2

33

    }

26

    include_once(DEDEINC."/channelunit.func.php");

5

2

17

15

 

 

13

        $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath

8

 

function GetOneDocUrl($aid)

这样就指定调用栏目ID 为 7和8的栏目

    {

11

                    where arc.id='$aid' ";

 

18

    if($chRow['issystem']!=-1)

20

4

 

16

24

28

a.writer=~writer~  调用当前文章的作者,调用指定的作者,可以这样写a.writer='admin'  这样就是指定调用admin这个作者的文档

    if(!is_array($chRow)) {

6

            <li>文章ID:[field:id/]</li>

31

25

                    where arc.aid='$aid' ";

7

GetOneDocUrl 函数 放到incluce/extend.func.php 文件中,这个函数是用来调用文档的静态URL的。

4

{

        return $reArr;

    $arcRow = $dsql->GetOne($nquery);

    else {

    return $Url;

    global $dsql;

                    From `{$chRow['maintable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid

        if(empty($chRow['maintable'])) $chRow['maintable'] = 'dede_archives';

    }

30

        $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath

模板里调用SQL:

21

 

22

27

3

    $Url = GetFileUrl($aid,$arcRow['typeid'],$arcRow['senddate'],$reArr['title'],$arcRow['ismake'],$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']);

12

指定调用2个栏目的话  可以把where a.typeid='7'  修改为 where a.typeid='7' and a.typeid='8'

    }

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/jz/dedecms/3621.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

dedecms 调用指定栏目,指定作者,指定自定义字段

2020-12-14 编辑:

    else

14

a.typeid=7   调用ID为7的栏目  如果不需要指定栏目ID  那么你可以把 a.typeid='7' and  删掉

29

23

b.sex=男  设置性别,也就是自定义字段。如果你的自定义字段不是sex 那么你只要把sql里的b.sex 改成你的字段,例如 name 改成b.name

                    From `{$chRow['addtable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid

32

          {/dede:sql}

    }

6

            <li>标题:<a href="[field:id function='GetOneDocUrl(@me)'/]">[field:title/]</a></li>

            <li>性别:[field:sex/]</li>

    $aid = trim(ereg_replace('[^0-9]','',$aid));

    $chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `dede_arctiny` arc left join `dede_channeltype` ch on ch.id=arc.channel where arc.id='$aid' ");

 

{dede:sql sql="select a.id,a.title,a.writer,a.pubdate,a.typeid,b.aid,b.sex from dede_archives a LEFT JOIN dede_addonarticle b on b.aid=a.id where a.typeid='7' and a.writer=~writer~ and b.sex='男' order by a.pubdate desc LIMIT 0,5"}

1

 

19

            <li>作者:[field:writer/]</li>

9

3

    {

百度知道里看到有人提问,帮写了一个。

1

10

LIMIT 0,5  设置要调用的条数,我这里写的是5条,自行修改.

5

2

33

    }

26

    include_once(DEDEINC."/channelunit.func.php");

5

2

17

15

 

 

13

        $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath

8

 

function GetOneDocUrl($aid)

这样就指定调用栏目ID 为 7和8的栏目

    {

11

                    where arc.id='$aid' ";

 

18

    if($chRow['issystem']!=-1)

20

4

 

16

24

28

a.writer=~writer~  调用当前文章的作者,调用指定的作者,可以这样写a.writer='admin'  这样就是指定调用admin这个作者的文档

    if(!is_array($chRow)) {

6

            <li>文章ID:[field:id/]</li>

31

25

                    where arc.aid='$aid' ";

7

GetOneDocUrl 函数 放到incluce/extend.func.php 文件中,这个函数是用来调用文档的静态URL的。

4

{

        return $reArr;

    $arcRow = $dsql->GetOne($nquery);

    else {

    return $Url;

    global $dsql;

                    From `{$chRow['maintable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid

        if(empty($chRow['maintable'])) $chRow['maintable'] = 'dede_archives';

    }

30

        $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath

模板里调用SQL:

21

 

22

27

3

    $Url = GetFileUrl($aid,$arcRow['typeid'],$arcRow['senddate'],$reArr['title'],$arcRow['ismake'],$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']);

12

指定调用2个栏目的话  可以把where a.typeid='7'  修改为 where a.typeid='7' and a.typeid='8'

    }

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/jz/dedecms/3621.shtml

相关文章

风云图片

推荐阅读

返回织梦cms频道首页