DEDECMS织梦调用某个作者在某个栏目发布的文章列表

2022-08-18

这个调用,使用范围比较广泛。例如:在装饰公司,案例是一个栏目,设计师是一个栏目。设计师的详情页如何调用自己的案例呢?这个开发方法织梦58就在这里分享下

只需要把案例的作者 和设计师详情页的作者设为一个即可。调用案例的栏目的id。 下面是具体的调用方法

调用方法

在某个作者发布的文章内容页中调用如下代码:

    {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"}

               

  • 文章ID:[field:id/]
  •                

  • 标题:

    [field:title/]

  •                

  • 作者:[field:writer/]
  •                

  • 性别:[field:sex/]
  •                

                  {/dede:sql}

        /*

        *如果模型是图集把dede_addonarticle改为dede_addonimages即可

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

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

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

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

        *  指定调用2个栏目的话  可以把where a.typeid='7'  修改为 where a.typeid='7' and a.typeid='8'。这样就指定调用栏目ID 为 7和8的栏目。

     

        */

    以上代码中,调用了一个函数GetOneDocUrl();所以,需要在 incluce/extend.func.php 文件中把该函数写上。这个函数的功能是:通过id调用文章的静态url。具体函数代码如下:

        function GetOneDocUrl($aid)

        {

            global $dsql;

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

            $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' ");

        

            if(!is_array($chRow)) {

                return $reArr;

            }

            else {

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

            }

        

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

            {

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

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

                            where arc.id='$aid' ";

            }

            else

            {

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

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

                            where arc.aid='$aid' ";

            }

        

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

        

            $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']);

            return $Url;

        }

    完成。

    非凡技术导航 优秀网址导航免费网站收录 网站地图

    本站收录的网站若侵害到您的利益,请联系我们删除处理

    Copyright ©2020 Guojiz V 5.5All Rights Reserved.

    备案号 )| 1735737677|