How to get the top-level column name of the current column of DreamWeaver cms?
When doing some projects with Dreamweaver, we often encounter the need to call the top-level column name on the current page. Dreamweaver defaults to {dede:field name='typename' /} to get the current The name of the upper-level column on the column page, not the top-level column name of the current column.
Recommended learning: Dream Weaver cms
Be sure to pay attention to whether you need to modify the prefix of the query statement table when using it
The following is a method to expand To achieve this effect, add:
at the bottom of include/common.func.php:
//获取顶级栏目名 function GetTopTypename($id) { global $dsql; $row = $dsql->GetOne("SELECT typename,topid FROM dede_arctype WHERE id= $id"); if ($row['topid'] == '0') { return $row['typename']; } else { $row1 = $dsql->GetOne("SELECT typename FROM dede_arctype WHERE id= $row[topid]"); return $row1['typename']; } }
When calling on the article page or column list page, add the following in the position of the name to be called This line of code does it.
{dede:field name='typeid' function="GetTopTypename(@me)" /}
Use the following method to call
{dede:field name='typeid' function="GetTopTypename(@me) /}
========================== =========
dedecms Obtaining the top-level column name and the second-level column name Implementation method
I encountered a problem when I was doing the website today. It needs to be at the second and third levels. , or even more levels, to obtain the top-level column or second-level column name.
Now I would like to share with you the simplest implementation method. Find the include/common.func.php file and add the following code in it:
//获取二级栏目名 function GetTopTypename($id) { global $dsql; $row = $dsql->GetOne("SELECT typename,reid FROM gsh_arctype WHERE id= $id"); if ($row['reid'] == '0') { return $row['typename']; } else { $row2 = $dsql->GetOne("SELECT typename FROM gsh_arctype WHERE id= $row[reid]"); return $row2['typename']; } }
Then add it to any list page or content page where the name needs to be called:
{dede:field.typeid fuction="GetToypename(@me)"/}
If in dede In the tag, use the following call:
[field:typeid fuction="GetToypename(@me)"/]
The above method is to call the secondary column name of the column. If you need the top-level column name, just change the reid field in the SQL to topid. Also remember to change the gsh_arctype prefix to the prefix of your database.
The above is the detailed content of How to get the top column name of the current column of Dreamweaver CMS. For more information, please follow other related articles on the PHP Chinese website!