Dede Show Full caption when no abbreviated title

Source: Internet
Author: User

The title of the news needs to be a word limit, which requires adding a title attribute, so that the full caption is displayed when the mouse is placed. In addition, the current call can only invoke a title method at the same time, but you can use the following methods to judge, no short title display full title. For example, in earlier versions of Dede, "source shows source, no source does not show", "there is author display author, no author does not show".

This is a long title display long title, no long title is displayed short title, need to use the reverse, you can Shorttitle and title swap a position.

Method One:

{Dede:field name='array' runphp='Yesif (@me ['shorttitle']==') @[email protected]['title'];  else @[email protected]['shorttitle           


Method Two:

[Field:array runphp='Yesif (@me ['shorttitle']== ') @[email protected]['title ']; else @[email protected]['shorttitle'];[ /field:array]             

Method Two (attached):

[Field:array runphp='Yesif (@me ['title']==') @[email protected]['shorttitle ']; else @[email protected]['title'];[ /field:array]             

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

Method Three:
Sometimes the title is too long, all display will cause the typesetting confusion, the influence is beautiful. But the display part also affects the user experience. We hope that when the title in a certain length of time, the full title display, when the title is outdated, only display a certain length, followed by an ellipsis, and then when the mouse moved up to display the title of the whole content, so that does not affect the layout of layout, but also to achieve the title of the full display of content.

This gives you a way to modify only the template without modifying the program. For example, the following list of headings, the longest title 50 bytes, just want to display 30 bytes, the template code is as follows:

 <ul> {dede:arclist Titlelen= ' } <li><a title=  "[field:title/]" href = "[field:filename/]" >[field:title function= '  (strlen ("@me") >30? Cn_ substr ("@me", 30). " ... ":" @me ")  '/]</a></li> {/dede:arclist} </ul>             

Obviously, the key to solving the problem is to use [Field:title function= ' (strlen ("@me") >34 cn_substr ("@me", 30). " ... ":" @me ") '/] instead of the original [Field:title/], in the output header more than a judgment process, first determine whether the title is greater than 34 bytes, if greater than the output of only 30 bytes of length, and add the ellipsis. The title= "[Field:title/]" is unaffected, and the entire contents of the caption are displayed when the mouse is moved up.

Method Four:
In addition to the method of modifying the template above, there are methods such as programming or CSS. But the problem that can be solved by the template, programming is not necessary. The CSS method is as follows:

<a style= "width:120px; Text-overflow:ellipsis; White-space:nowrap; Overflow:hidden, "title=" DedeCMS2007 upcoming release "Href=" ">dedecms2007 upcoming release </a>

Explanation: width:120px; Limit length, text-overflow:ellipsis: show ellipsis when text overflows in object ..., White-space:nowrap: Force text to appear on one line, Overflow:hidden: Overflow content is hidden.

The CSS method is simpler than modifying the template, but unfortunately, the text-overflow:ellipsis attribute is not effective in Firefox. So, let's use the above method of modifying the template.

Dede title link, there is can link no then not connected

{Dede:list pagesize=‘15‘orderby=‘Weight' Orderway=‘Desc‘} <dl> <dt>[field:pubdate function=‘Strftime ("%y/%m/%d", @me)'/]</dt> <dd>[Field:array runphp=‘Yes‘]if (@me [‘Body']==") @[email protected][‘Title‘];else{@me =‘<a href= "" arcurl ".  '  "[Email  protected][ ' description  ".  ' " title ".  ' </a>field:array] </dd> </dl> {/dede:list}  

Dede Show Full caption when no abbreviated title

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.