/*** 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