The length of the title displayed by the smarty list plug-in and the connection solution

Source: Internet
Author: User
The smarty list plug-in displays the title length and connection. now, you need to write a list plug-in the smarty plug-in to intercept the title length. PHPcode & lt ;? Phpfunctionsmarty_function_list ($ params, & amp; $ smarty) {extract ($ param smarty list ins display title length and connection
Now I am writing a website. I want to write a list plug-in the smarty plug-in. I want to extract the title length.
PHP code
  
  PageExecute ($ SQL, $ pagesize, $ page); $ rs = $ rs-> getRows (); $ smarty-> assign ($ length, $ length ); $ smarty-> assign ($ varname, $ rs); unset ($ rs) ;}?>

The above is the plug-in code;
HTML code
  {--list cate="articles" items="Title" length=4 varname="rs"--}{--foreach from=$rs item=r--}{--$r.Title--}
{--/foreach--}

The above is the template code.
Now we want to intercept the title length and connect it with the title.
$ R. Titletruncatecn: $ length: "...": true
This is not acceptable! Thank you!

------ Solution --------------------
Discussion

Where does $ length come from?

If it changes, try this.
$ R. Title | truncate: '$ length': "...": true
Specify a specific number.
$ R. Title | truncate: 30: "...": true

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.