The Empire tag template uses program code to remove html tags and truncate strings

Source: Internet
Author: User

When using the Empire tag template, you must intercept the string, but if you setIntroductionThe html Tag is displayed on the front-end. My solutions are now released. The first user of my empire. If the problem occurs, you are welcome to leave a comment. Forget to communicate with each other

The Empire tag template uses program code to remove html tags and truncate strings

1. Add a user-defined function to the e/class/connect. php file.How to remove html tagsNoHTML ()

 

1 // remove HTML tags
2 function NoHTML ($ string ){
3 $ string = preg_replace ("'<script [^>] *?>. *? </Script> 'si "," ", $ string); // remove javascript
4 $ string = preg_replace ("'<[\/\!] *? [^ <>] *?> 'Si "," ", $ string); // remove the HTML Tag
5 $ string = preg_replace ("'([\ r \ n]) [\ s] +'", "", $ string); // remove the white space
6 $ string = preg_replace ("'& (quot | #34);' I", "", $ string); // replace an HTML Object
7 $ string = preg_replace ("'& (amp | #38);' I", "", $ string );
8 $ string = preg_replace ("'& (lt | #60);' I", "", $ string );
9 $ string = preg_replace ("'& (gt | #62);' I", "", $ string );
10 $ string = preg_replace ("'& (nbsp | #160);' I", "", $ string );
11 return $ string;
12}

2. List content template code:

 

1 $ r [smalltext] = esub (NoHTML ($ r [smalltext]), 200 ,'......');
2 $ listtemp = '<li> <strong> <a href = "[! -- Titleurl --] "> [! -- Title --] </a> </strong> <p> [! -- Smalltext --] </p> </li> ';

 

Success.

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.