Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the ways to get the dream weaving dedecms sub-column?

Shulou Source: shulou.com Published: 2022-06-02 05:00:10 10月04日 Update

I would like to share with you the ways to get the dream weaving dedecms sub-column. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.

How to get the dream weaving dedecms sub-column?

Dedecms5.7 gets the label of the top-level column name

Recommended study: dream weaving cms

The following is the method to call the top-level column name:

Method 1:

{dede:field.typeid runphp='yes'} $ID = @ me; $sql = "SELECT * FROM `dede_ arctype` WHERE id=$ID"; $query = mysql_query ($sql); $row=mysql_fetch_array ($query); $relID = "$row [reid]"; if ($relID = = 0) {@ me = $row [typename];} else {$sql = "SELECT `typename` FROM `dede_ arctype` WHERE id=$relID"; $query = mysql_query ($sql); $row=mysql_fetch_array ($query); @ me = $row[ typename];} {/ dede:field.typeid}

The statement of this method is a bit long.

Method 2:

{dede:field.title runphp='yes'} list ($toptype,$sontype) = split ('/', @ me); @ me=$toptype; {/ dede:field.title}

Method 3:

{dede:field.typeid runphp='yes'} $ID= @ me; $sql = "SELECT * FROM `dede_ arctype` WHERE id=$ID"; $query = mysql_query ($sql); $row=mysql_fetch_array ($query); $relID = "$row [reid]"; $topID= "$row [topid]"; if ($relID = = 0) {@ me = $row [typename];} else {$sql = "SELECT `typename` FROM `dede_ arctype` WHERE id=$topID"; $query = mysql_query ($sql); $row=mysql_fetch_array ($query); @ me = $row [typename];} {/ me}

Method 4 (recommended):

Open include/helpers/extend.helper.php and add a function:

/ * get the name of the top column of the specified column id * * @ return string * / if (! Function_exists ('getTopChannelName') {function getTopChannelName ($id) {global $dsql; $typeinfo = $dsql- > GetOne ("SELECT * FROM `dede_ arctype` WHERE id=' {$id}'"); if ($typeinfo ['reid'] = = 0) return $typeinfo [' typename']; else return getTopChannelName ($typeinfo ['reid']);}}

Use this on the list page: {dede:field name='id' function='getTopChannelName (@ me)'/}

Use this on the content page: {dede:field name='typeid' function='getTopChannelName (@ me)'/}

The url that gets the top column is attached:

Open include/helpers/extend.helper.php and add a function:

/ * get the url * * @ return string * / if (! Function_exists ('getTopChannelUrl')) {function getTopChannelUrl ($id) {global $dsql; $typeinfo = $dsql- > GetOne ("SELECT * FROM `dede_ arctype` WHERE id=' {$id}'"); if ($typeinfo ['reid'] = = 0) return GetOneTypeUrlA ($typeinfo); else return getTopChannelUrl ($typeinfo [' reid']);}}

The usage is the same as above.

The above is how to get all the contents of the Weaving Dream dedecms sub-column. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Columns methods top-level content name function article learning recommendation not much usage most more tags knowledge industry sentences information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Shulou Information Apple MariaDB