Example of how Dedecms obtains the current column path and column name

黄舟
Release: 2023-03-07 08:16:01
Original
2008 people have browsed it

This article mainly introduces the method of Dreamweaver dedecms to obtain the current column path and column name. Friends who need it can refer to the

dedecms template download address: www.php.cn/xiazai/code/dedecms

The tags are as follows:
Current:

The code is as follows:

{dede:type}
<a href=" [field:typelink  /] "> [field:typename/] </a>
{/dede:type}
Copy after login

Because {dede:field name='arcurl'/} this tag to get the current page path only It can be used on content pages, but has no effect on column pages. Therefore, if you want to get the path and name of the current column on the column page, you must use the above tag.
To get the list of all column names and paths on the website, you need to use another tag: {dede:channel}, the calling method is as follows:
All columns

The code is as follows:

<ul>
{dede:channel  type=&#39;
top
&#39; row=&#39;11&#39;}
<li class="navbg"><a  href=&#39;[field:typelink/]&#39;>[field:typename/]</a></li>
{/dede:channel}
</ul>
Copy after login

Tutorial on how to get the label of the top column name of the current column on the dedeCMS website column page:
When we use and build some websites, we often encounter the need to call the top column name of the current column. By default, Dreamweaver defaults {dede:field name='typename' /} can get the name of the upper-level column on the current column page, instead of the top-level column name of the current column.
The following is a method to achieve this effect:
Add at the bottom of include/common.func.php:
The content comes from
Top column name

The code is as follows:

function GetTopTypename($id)
{
    global $dsql;
     $row = $dsql->GetOne("SELECT typename,topid FROM jiemou_arctype WHERE id=  $id");
    
if
 ($row[&#39;topid&#39;] == &#39;0&#39;)
    {
        
return
  $row[&#39;typename&#39;];
    }
    
else
    {
        $row1 =  $dsql->GetOne("SELECT typename FROM jiemou_arctype WHERE id=  $row[topid]");
        return $row1[&#39;typename&#39;];
    }
}
Copy after login

When calling on the article page or column list page, add the following line of code to the position of the column name to be called. Content comes from
{dede:field name='typeid' function="GetTopTypename(@me)" /} Content comes from
Use the following method on the article page to call
Get the parent column of the current column
Write it as a function and put it in the include/extend.func.php file

The code is as follows:

function GetParentCategoryNameByID($
Current
ID){
$tsql = 
new
 DedeSql(false); 
$typelink2 = &#39;&#39;;
$tsql->
Set
Query("Select i.type
dir
,i.typename From zz5unet_arctype t 
left
 join zz5unet_arctype i on i.id=t.reid where t.id=&#39;$CurrentID&#39;");
$tsql->Execute(&#39;t&#39;);   
while
($row = $tsql->Get
Array
(&#39;t&#39;,
MYSQL
_ASSOC))  
{
$typelink2 .= $row[&#39;typename&#39;];  
}
return $typelink2;
}
Copy after login

Calling method:

{dede:field name=&#39;id&#39; function=&#39;GetParentCategoryNameByID(@me)&#39; /}
Copy after login

The above is the detailed content of Example of how Dedecms obtains the current column path and column name. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template