A method of invoking the name of a specified top-level column or current sub-column

Source: Internet
Author: User

Sometimes we will call the list page or the Content Detail page designated top-level column name and link, try a lot of methods, some can only call all top-level columns or sub-columns below the channel, it is very confusing. Let's talk about the method of calling the various column names:

1, {Dede:field name= "typename"} This is the name of the calling current column
2. {dede:channel type= ' son ' row= ' 5 '} <a href= "[field:typeurl/]" >[field:typename/]</a> {/dede:channel} This is the call to the top channel all the word column, row represents the call 5
3, {dede:type typeid= ' column ID '} <a href= "[field:typeurl/]" >[field:typename/]</a> {/dede:type} represents the column that invokes the specified ID, However, only one can be called, and multiple calls can only be repeated multiple times to call the label
4, {dede:channel type= ' top '}<a>[field:typename/]</a> {/dede:channel} call sub-column of the current top-level column name

Here's how to invoke the top-level column name:
Method One:

{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}

This method statement is somewhat long.
The key recommendation method of Weaver Dreamer II
Method Two:

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

Method Three:

{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];} {/dede:field.typeid} 

This method is improved, can be for the infinite sub-column to obtain top-level columns, method one or two is for two columns.

A method of invoking the name of a specified top-level column or current sub-column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.