SoFunction
Updated on 2025-03-10

Dedecms call discuz forum information classified according to ID call with detailed instructions

What we are talking about here is not the js call method of the dizcuz background. One is that it cannot type well according to your needs, and the other is that it is not friendly to search engines. Here we need to be loop tag mode.
Copy the codeThe code is as follows:

//Get any table content
    function GetTable($tablename="",$row=6,$sort="",$ifcase="",$InnerText=""){
        $InnerText = trim($InnerText);
        if($tablename==""||$InnerText=="") return "";
        $row = AttDef($row,6);
        if($sort!="") $sort = " order by $sort desc ";
        if($ifcase!="") $ifcase=" where $ifcase ";
        $revalue="";
        $this->dsql->SetQuery("Select * From $tablename $ifcase $sort limit 0,$row");
        $this->dsql->Execute();
        $ctp = new DedeTagParse();
        $ctp->SetNameSpace("field","[","]");
        $ctp->LoadSource($InnerText);
        while($row = $this->dsql->GetArray())
    {
          foreach($ctp->CTags as $tagid=>$ctag){
            if(!empty($row[$ctag->GetName()]))
            { $ctp->Assign($tagid,$row[$ctag->GetName()]); }
          }
          $revalue .= $ctp->GetResult();
        }
        return $revalue;
    }

From the above code, it can be seen that the parameters in if are actually judgment statements. You can refer to the table to output them arbitrarily.
1 The latest theme call method of the forum:

Code

{ dede:loop table="cdb_threads" sort="tid" row="10" }
<a href="/dz/?tid=[field:tid /]">
·[field:subject function="cn_substr(' at me',30)" /]([field:lastpost function="date('m-d H:M','@me')" /])
</a>
<br/>
{ /dede:loop }


2. Forum specified section call method:
{ dede:loop table="cdb_threads" if="fid=1 or fid=2 and displayorder!=-1" sort="tid" row="6" }
<a href="/bbs/viewthread dot php?tid=[field:tid /]" target="_blank">
·[field:subject function="cn_substr(' at me',50)" /]
</a>
<br/>
{ /dede:loop }


3. Forum top section call method 2:
{ dede:loop table="cdb_threads" sort="dateline" if="fid='3' and typeid='51'" row="10" }
<a href="/a/bbs/viewthread dot php?tid=[field:tid /]" target="_blank">
·[field:subject function="cn_substr(' at me',30)" /]</a> <br>
{ /dede:loop }


4 Forum section name call method:
{ dede:loop table="cdb_forums" sort="displayorder" row="16" col="4" }
 <a href="/bbs/viewthread dot php?fid=[field:fid /]">·[field:name function="cn_substr(' at me',30)" /]
</a>
{ /dede:loop }
Note: There is still some problem with this, it will call out the forum partition and section.



Attachment: Dedecms' LOOP tagging rules

Function description: used to call data from any table, generally used to call operations such as forum posts
Scope of application: All templates
(1) Basic syntax
{ dede:loop table=' sort='' row='' if='' } 
Bottom template
{ dede:loop } 
(2) Attributes
[1] table representing the query data table
[2] sort fields used for sorting
[3] row Return the number of results
[4] if Query Conditions
(3) Underlying template variable
The underlying template variable of this tag is all fields of the query table.

===========================================

The latest topic of the forum:<br/>
{dede:loop table="cdb_threads" if="fid=9 and displayorder!=-1" sort="tid" row="10"}
<a href="/dz/?tid=[field:tid /]">
·[field:subject function="cn_substr('@me',30)" /]([field:lastpost function="date('m-d H:M','@me')" /])
</a>
<br/>
{/dede:loop}