Dedecms Restriction
As we all know, sometimes, when the title of a webpage article is too long, it will affect the appearance of the webpage, so we need to trim it to limit how many texts it will display, the extra parts are replaced by ellipsis.
So how can we achieve this with dedecms? The following are three methods for your reference:
1. Modify CSS:
<A style = "width: 120px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; "href =" XXXXX "> webpage articles are long, long, and long titles </a>
Explanation: width: 120px; limited length, text-overflow: ellipsis: when the text in the object overflows, the omitted 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. 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.
Wu Lei prefers this method. He only needs to modify the template, which has little impact on the system.
3. Modify the dedecms program method:
Add a fulltitle label for your title = "" to display the Complete title
The specific modification is as follows:
1. Open the inc_fun_spgetarclist.php file under the INC directory under the include directory.
2. Find row 228
$ Row ['title'] = cn_substr ($ row ['title'], $ titlelen );
Add a line above
$ Row ['fulltitle'] = $ row ['title']; // Note: displays the Complete title.
3. Find
Copy code
$ Row ['textlink'] = "<a href = '". $ row ['filename']. "'> ". $ row ['title']. "</a> ";
Replace it:
$ Row ['textlink'] = "<a href = '". $ row ['filename']. "'title = '". $ row ['fulltitle']. "'> ". $ row ['title']. "</a> ";
I do not like it. I think it is relatively advanced to modify the background program, but I am a little confused about the background logic of a simple display problem, however, we can use this to add a deeper understanding of Dede string processing.