Zhimeng calls all columns (unlimited column output)

Share 2 ways to get all columns of Zhimeng (unlimited column output)

The first method of custom function recursion

For simple style users in the front end, add at the bottom of include/extend.func.php

/**
* Take out all categories
* @param     int   $channel  channel ID
* @return    string
* call{dede:global.getalltype function='getalltype()'/}
*/

function getalltype($channel=0,$line=10)
{
    $line = empty($line) ? 10 : $line;
    global $dsql,$result;

    $dsql->SetQuery("SELECT id,typename,typenamedir,typelitpic,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
            FROM `#@__arctype` WHERE reid='$channel' And ishidden<>1 order by sortrank asc limit 0, $line ");
    $dsql->Execute($channel);
    if($dsql->GetTotalRow($channel)>0)
    {
        $result .= "<ul>\r\n"; 
        while($row = $dsql->GetArray($channel))
        {
            $id = $row['id'];
            $typename = $row['typename'];
            $typelink = GetOneTypeUrlA($row);

            $result .= "   <li>\r\n";
            $result .= "		<a href='{$typelink}' target='_blank'>{$typename}</a>\r\n";
            getalltype($id,$line);
            $result .= "   </li>\r\n";
        }
        $result .= "</ul>\r\n";
    }
    return $result;
}

Foreground template call label

{dede:global.getalltype function='getalltype()'/}

The second method of label nesting

It is applicable to users who only call level 1, level 2, level 3 and level 4, and write directly in the template

<ul>
    {dede:channelartlist row=7 typeid=top}
    <!-- top-level -->
    <li class="top">
        <a href="{dede:field.typeurl/}" >{dede:field name='typename'/}</a>
        <ul class="sub">
        {dede:channel type=son noself=yes}
        <!-- second level -->
        <li>
        <a href="[field:typeurl/]"  title="[field:typename/]">[field:typename/]</a>
        <ul>
<!-- Level three -->
[field:id runphp=yes]
global $dsql;
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid=@me And ishidden<>1 order by sortrank asc limit 0,10";
$dsql->SetQuery($sql);
$dsql->Execute('t');
$result = '';
while($row = $dsql->GetArray('t'))
{
    $typename = $row['typename'];
    $typeurl = GetOneTypeUrlA($row);
$result .= <<< TPL
<li><a href="{$typeurl}">{$typename}</a></li>
TPL;
}
@me = $result;
[/field:id]
        </ul>
        </li>
        {/dede:channel}
        </ul>
    </li>    
    {/dede:channelartlist}
</ul>

The above is output to level 3 column. If you need level 4 column, you can write like this

<!-- Level three/Level Four -->
[field:id runphp=yes]
global $dsql;
$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid=@me And ishidden<>1 order by sortrank asc limit 0,10";
$dsql->SetQuery($sql);
$dsql->Execute('t');
$result = '';
while($row = $dsql->GetArray('t'))
{
    $row['typeurl'] = GetOneTypeUrlA($row);
    $result .= "<a href='{$row[typeurl]}'>{$row[typename]}</a>";
    //Level Four
    $nsql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `#@__arctype` WHERE reid=$row[id] And ishidden<>1 order by sortrank asc limit 0,10";
    $dsql->SetQuery($nsql);
    $dsql->Execute('n');
    while($nrow = $dsql->GetArray('n'))
    {
        $nrow['typeurl'] = GetOneTypeUrlA($nrow);
        $result .= "<a href='{$nrow[typeurl]}'>{$nrow[typename]}</a>";
    }
}
@me = $result;
[/field:id]

Tags: SQL PHP

Posted on Thu, 02 Apr 2020 21:00:39 -0700 by hastishah