Home > Article > Backend Development > Example of how Dedecms obtains the current column path and column name
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: m.sbmmt.com/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}
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=' top ' row='11'} <li class="navbg"><a href='[field:typelink/]'>[field:typename/]</a></li> {/dede:channel} </ul>
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['topid'] == '0') { return $row['typename']; } else { $row1 = $dsql->GetOne("SELECT typename FROM jiemou_arctype WHERE id= $row[topid]"); return $row1['typename']; } }
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 = ''; $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='$CurrentID'"); $tsql->Execute('t'); while ($row = $tsql->Get Array ('t', MYSQL _ASSOC)) { $typelink2 .= $row['typename']; } return $typelink2; }
Calling method:
{dede:field name='id' function='GetParentCategoryNameByID(@me)' /}
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!