Home > CMS Tutorial > DEDECMS > body text

How to get the top column name of the current column of Dreamweaver CMS

藏色散人
Release: 2019-12-16 09:55:20
Original
1940 people have browsed it

How to get the top column name of the current column of Dreamweaver CMS

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'];
  
}
  
}
Copy after login

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)" /}
Copy after login

Use the following method to call

{dede:field name='typeid' function="GetTopTypename(@me) /}
Copy after login

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

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'];
  
  } 
}
Copy after login

Then add it to any list page or content page where the name needs to be called:

{dede:field.typeid fuction="GetToypename(@me)"/}
Copy after login

If in dede In the tag, use the following call:

[field:typeid fuction="GetToypename(@me)"/]
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!