DedeCMS extension method for getting the URL of the document and topic

Source: Internet
Author: User

/*** Obtain the complete URL of the topic by Windchaser QQ: 939238564 * @ param $ typeid column ID | Document ID * @ link http://down.chinaz.com/try/201202/1646_1.htm adapted from the article code based on * @ return String */function typeurl_arc ($ typeid, $ type = 'tid ') {global $ dsql, $ cfg_basehost; if ($ type = 'tid') {// obtain the complete URL of the topic $ typeurl = ''; $ row = $ dsql-> GetOne ("SELECT typedir, namerule2, isdefault, typedir, defaultname FROM dede_arctype WHERE id = $ typeid"); $ row ['name Rule2'] = str_replace ('{typedir}', '', $ row ['namerule2']); $ row ['namerule2'] = str_replace ('{tid }', $ typeid, $ row ['namerule2']); $ row ['namerule2'] = str_replace ('{page}', 1, $ row ['namerule2']); $ row ['typedir'] = str_replace ('{cmspath}', '', $ row ['typedir']); switch ($ row ['isdefault']) {case 0: // link to the first page of the list $ typeurl = $ row ['namerule2']; break; case 1: // link to the category page $ typeurl = $ row ['typedir']. '/'. $ row ['defaultname' ]; Break; default: // use the dynamic page $ typeurl = '/plug/list. php? Tid = '. $ typeid; break ;}} else if ($ type = 'aid ') {// get the complete URL of the document $ row = $ dsql-> GetOne ("SELECT cnn. namerule, arc. ismake, arc. senddate FROM dede_archives arc JOIN dede_arctype cnn ON arc. typeid = cnn. id WHERE arc. id = $ typeid "); if ($ row ['ismake'] = 1) {if (strpos ($ row ['namerule'], '/') = 0) {$ row ['namerule'] = substr ($ row ['namerule'], 1 );} $ row ['namerule'] = str_replace ('{aid}', $ typeid, $ row ['namerule']); $ r Ow ['namerule'] = str_replace ('{Y}', date ('y', $ row ['senddate']), $ row ['namerule']); $ row ['namerule'] = str_replace ('{M}', date ('M', $ row ['senddate']), $ row ['namerule']); $ row ['namerule'] = str_replace ('{D}', date ('D', $ row ['senddate']), $ row ['namerule']); $ typeurl = '/'. $ row ['namerule'];} else {$ typeurl = '/plug/view. php? Aid = '. $ typeid; }}$ typeurl = $ pai_basehost. $ typeurl; return $ typeurl ;}

DEDECMS template tag extension method!

The purpose is to obtain the complete URL of a topic or document!

The tag call for the document and list is different!

List:

{dede:field.typeid function='typeurl_arc(@me)'/}

Documentation:

{dede:field.id function='typeurl_arc(@me,aid)'/}


This article from the "against the wind" blog, please be sure to keep this source http://windchaser.blog.51cto.com/5742634/1301449

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.