Dede implements the Jump property document invokes a jump address _php instance on the template

Source: Internet
Author: User

First, add the following methods to the/include/extend.func.php:

/**
 * Dynamic address to static output by Windchaser qq:939238564
 * $arcurl dynamic URL
 * @return String
 *
/function arcurlhtml ($ Arcurl) {
  preg_match ('/view.php\?aid= (\d+)/', $arcurl, $arcid);
  if (!empty ($arcid) && Is_array ($arcid)) {//Match exists dynamic address
    global $dsql;
    $addtable = $dsql->getone ("Select Channel.addtable from #@__channeltype as channel left JOIN #@__archives as arc on arc . channel=channel.id
WHERE arc.id= ' {$arcid [1]} ');//Get Model Type table name
    $redirecturl = $dsql->getone ("Select RedirectURL from {$addtable [' addtable ']} WHERE aid = ' {$arcid [1]} ');//dynamically get table name and query redirecturl field data
    if (!empty $ redirecturl[' RedirectURL ']) {
      return $redirecturl [' RedirectURL '];//returns redirecturl field data
    }else{
      return $arcurl;
    }
  else{//non dynamic address return directly to the original address
    $arcurl;
  }

There are two forms of how you use the template:

#第一种:
[Field:arcurl function= ' arcurlhtml (@me) '/]
#第二种:
[field:id runphp= ' yes '] $id = @me; @me = '; $url = Getonearchive ($id); @me = $url [' Arcurl ']; @me =arcurlhtml (@me); [/field:id]

Full Call:

#第一种
{dede:arclist titlelen= ' channelid= '-1 ' limit= ' 0,4 ' type= commend ' flag= ' ' <li ' C '}
       class= "Rtli" ><a href= "[Field:arcurl function= ' arcurlhtml (@me) '/]" title= "[field:title/]" target= "_blank" ></a></li>
     {/dede:arclist}
#第二种
{dede:sql Sql= "SELECT * from Xzzj_channeltype a LEFT join xzzj_archives b ' a.id = B.channel where a.id=-1 order by B.pubdate DESC LIMIT 0,2 "}
        <a href=" [field:id runphp= ' yes '] $id = @me; @me = '; $url =getonearchive ($id); @me = $url [' Arcurl ']; @me = Arcurlhtml (@me); [/field:id] "class=" S_contentrtpia "target=" _blank "title=" [field:title/] "><span class=" S_contentrtpiaspan ">[field:title/]</" Span></a>
    {/dede:sql}

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.