Phpcms V9 label Tag pseudo-static implementation example

Source: Internet
Author: User
Tags php file php and urlencode


First, let the program output the URL link after the tag pseudo-static. Because phpcms has a URL rule management function, we can directly add a URL rule in URL rule management, remember the previous ID number, such as 33, which will be called in the code below, as shown below:


{$Tagpai_{$page0000.html

Write the phpcms URL rule in the code, open the phpcms/modules/content/tag. Php file, and find the following code:


$ Infos = $ keyword_data_db-> listinfo ($ where, ''id'desc', $ page, $ pagesize );

Add the following code to this line:


$ Urlrules = getcache ('urlrules', 'commons ');
$ Urlrule = $ urlrules [33]; // call a url rule

Then, run the following code in the file:


$ Infos = $ keyword_data_db-> listinfo ($ where, ''id'desc', $ page, $ pagesize );

To:


$ Infos = $ keyword_data_db-> listinfo ($ where, ''id'desc', $ page, $ pagesize, '', '9', $ urlrule, array ('tag' => urlencode ($ tag )));
The purpose is to add the previously configured url rule to the query statement.

Through the above operation, the URL output at the front end has been changed to a pseudo static form. However, if the URL is output at the front end of the website, you need to modify the template file of the website. Take the default phpcms template file as an example. Open phpcms \ templates \ default \ content \ show.html and find:


{APP_PATH} index. php? M = content & c = tag & a = lists & tag = {urlencode ($ keyword )}

Changed:


{App_path}{urlencode($keyword1_1__1.html

Open phpcms \ templates \ default \ content \ tag.html and set the paging tag

{$ Pages}
Changed:


{Str_replace ("_0.html", "_1.html", $ pages )}
Finally, let the Web server rewrite the link. Take Apache as an example, add the following rewrite rules in the. htaccess file:


RewriteRule ^ (. * )_(%0-9%%%%%.html index. php? M = content & c = tag & a = lists & tag = $1 & page = $2

The URL style shown at the end is as follows: http:/response. The solution is to open phpcms/modules/content/tag. php and find:


$ Tag = safe_replace (addslashes ($ _ GET ['tag']);

Add the following code below:

$ Tag = iconv ("gb2312", "UTF-8", $ tag); // transcode

If not, change the location of "gb2312" and "UTF-8. The above are all the tutorials on the tag tab pseudo-static of phpcms v9. The pseudo-static of phpcms is not much different from that of DedeCMS of Zhimeng. The two can be used for mutual reference.

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.