Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of obtaining the name of the top column in the current column of Weaving Dream cms

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of obtaining the name of the top column in the current column of Weaving Dream cms, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

How to get the top column name of the current column of Weaving Dream cms?

When doing some projects with dream weaving, you will often encounter the need to call the top-level column name on the current page. By default, {dede:field name='typename' /} can get the name of the top-level column on the current column page instead of the top-level column name of the current column.

Recommended study: dream weaving cms

When using it, you must pay attention to whether it is necessary to modify the prefix of the query statement table.

Here is a way to achieve this effect:

At the bottom of the include/common.func.php, add:

/ / get the top-level column name 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 line of code to the location of the name you want to call.

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

In the article page, use the following method to call

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

= =

The realization method of obtaining Top-level column name and second-level column name by dedecms

There is a problem when doing a station today. We need to get the top-level column or second-level column name at level 2, level 3, or even more.

Now I'd like to share with you the simplest way to implement it. Find the include/common.func.php file and add the following code to it:

/ / get the secondary column name 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 the following in any list page or content page where you need to call the name:

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

If it is in the dede tag, call it with the following sentence:

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

The above method is to call the second-level column name of the column. If you need the top-level column name, just change the reid field in SQL to topid. Also remember to change the gsh_arctype prefix to the prefix of your database.

Thank you for reading this article carefully. I hope the editor will share the methods and contents of getting the top column names in the current column of Weaving Dream cms. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report