Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of DedeCMS judging that the abbreviated title is empty and the complete title is displayed

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

How does DedeCMS judge that the abbreviated title is empty and the full title is displayed? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

How does DedeCMS judge that the abbreviated title is empty and the full title is displayed?

Preface

I believe we have all encountered, when we use the dream weaving DedeCMS system program to develop a website, we will encounter a lot of limited width due to the page layout, so that the title of the article needs to be limited by the number of words. The usual practice is to add a title attribute in the a tag to display the full title when the mouse is placed.

However, the title has been cut out of some characters and is incomplete. Here are several other title call methods recommended for you, such as title judgment. If DedeCMS judges that the abbreviated title is empty, the full title will be displayed.

The specific methods are as follows:

Method 1:

{dede:field name='array' runphp='yes'} if (@ me ['shorttitle'] = ='') @ me=@me ['title']; else @ me=@me [' shorttitle']; {/ dede:field}

Method 2:

[field:array runphp='yes'] if (@ me ['shorttitle'] = ='') @ me=@me ['title']; else @ me=@me [' shorttitle']; [/ field:array]

This method can be applied in the {dede:arclist} tag.

Method 3:

Sometimes the title is too long, all the display will lead to typesetting confusion, affecting the beauty. But the display part also affects the user experience. We hope that when the title is within a certain length, the full title will be displayed, when the title is out of date, only a certain length will be displayed, followed by an ellipsis, and then all the contents of the title will be displayed when the mouse is moved up, so that the layout of the page will not be affected, and all the contents of the title will be displayed.

Here is a method that does not need to modify the program, only the template. For example, the following list of titles, with the longest title of 50 bytes, only wants to display 30 bytes. The template code is as follows:

{dede:arclist titlelen='50' row='10'} [field:title function=' (strlen ("@ me") > 30? Cn_substr ("@ me", 30). "...": "@ me")'/] {/ dede:arclist}

Obviously, the key to solving the problem is to use [field:title function=' ("@ me") > 34? Cn_substr ("@ me", 30). "...": "@ me")'/] replaces the original [field:title /], adding a judgment process when outputting the title, first determining whether the title is larger than 34 bytes, and if so, only outputting a length of 30 bytes, with an ellipsis. The title= "[field:title /]" is not affected, and the full contents of the title are displayed when the mouse is moved up.

Method 4:

In addition to the above methods to modify the template, there are programming or CSS and other methods. But programming is not necessary for problems that can be solved through templates. The method of CSS is as follows:

DedeCMS2007 will be released soon.

Explanation: width:120px; limit length, text-overflow:ellipsis: show ellipsis marks when text overflows in an object..., white-space:nowrap: force text to be displayed on one line, overflow:hidden: overflow content is hidden. For more related tips, you can refer to this article: https://www.jb51.net/article/50258.htm

The method of CSS is easier than modifying the template, but unfortunately, the text-overflow:ellipsis attribute has no effect in firefox. So, use the above method of modifying the template.

Recently, another problem has been found, dede title links, some links can not be linked, the following is the solution:

{dede:list pagesize='15' orderby='weight' orderway='desc'} [field:pubdate function='strftime ("% Y/%m/%d", @ me)'/] [field:array runphp='yes'] if (@ me ['body'] = =') @ me=@me ['title']; else {@ me=''. @ me ['title'].'' } [/ field:array] {/ dede:list} Thank you for reading! After reading the above, do you have a general understanding of DedeCMS's method of judging that the abbreviated title is empty and the full title is displayed? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report