You all know how to modify dedecms's restricted title length and ellipsis. Sometimes, webpagesArticleWhen the title is too long, it will affect the appearance of the webpage. Therefore, we need to trim it to limit how many texts it only displays, and replace the extra content with a ellipsis. so how can we achieve this with dedecms? Several methods are listed below for your reference:
1. How to modify CSS: Here is the Title explanation: width: 120px; limited length, text-overflow: ellipsis: when the object text overflows, the omission mark is displayed ..., White-space: nowrap: forces the text to be displayed in a row. overflow: hidden: The overflow content is hidden. The method for modifying CSS is simple, but unfortunately, the text-overflow: ellipsis attribute is ineffective in Firefox.
2. How to modify the template: use [field: title function = '(strlen ("@ me")> 30? Cn_substr ("@ me", 30 )."..." : "@ Me") '/] replaces the original [field: Title/], and adds a judgment process when outputting the title. First, you can determine whether the title is greater than 30 bytes, if the value is greater than 30 bytes, only the length of 30 bytes is output, and the ellipsis is added. Title = "[field: Title/]" is not affected. When you move the cursor up, all the content of the title is displayed.
3. Add a function
Add a new function in include \ helpers \ string. helper. php.CodeAs follows:
/*** Chinese cut, the thumbnail ** @ access public * @ Param string $ STR refers to the string to be intercepted * @ Param int $ length intercepted by slen * @ Param int $ startdd start mark * @ Param string $ sq omitting character * @ return string */If (! Function_exists ('cn _ substr_sq ')){Function cn_substr_sq ($ STR, $ slen, $ startdd = 0, $ sq = "...") {$ sq = strlen ($ Str)> $ slen? "...":"";$ Text = cn_substr_utf8 ($ STR, $ slen, $ startdd). $ sq;Return $ text;}}
I put it in the string. Help. php file. This function depends on the cn_substr_utf8 function.