在織夢DEDECMS中調用文章,當標題超過限制字數時,怎么在標題后面加上……呢。其實不論是在首頁還是列表頁還是內容頁調用文章,不管是arclist還是list標簽調用文章,只需要把[field:title]這個標簽適當修改。
一般是類似于這樣:
1 |
{dede:arclist row= '10' } |
2 |
<li><a href= "[field:arcurl /]" title= "[field:fulltitle/]" >[field:title/]</a></li> |
如果需要限制字數,可以增加titlelen=’90′,代碼為:
1 |
{dede:arclist row= '10' titlelen= '90' } |
2 |
<li><a href= "[field:arcurl /]" title= "[field:fulltitle/]" >[field:title/]</a></li> |
但是,此時顯示的文章標題后面直接被截斷,不會有省略號,將其中的[field:title]修改成[field:fulltitle runphp='yes']$titlefull = @me;$titleshow =cn_substr($titlefull,90);if($titlefull!=$titleshow){$dot = “…”;}else{$dot=”";}@me = $titleshow.$dot;[/field:fulltitle]即可,代碼為:
1 |
{dede:arclist row= '10' } |
2 |
<li><a href= "[field:arcurl /]" title= "[field:fulltitle/]" >[field:fulltitle runphp= 'yes' ] $titlefull = @me; $titleshow =cn_substr( $titlefull ,90); if ( $titlefull != $titleshow ){ $dot = "…" ;} else { $dot = "" ;}@me = $titleshow . $dot ;[/field:fulltitle]</a></li> |
當然也可以修改成這樣:
1 |
{dede:arclist row= '10' } |
2 |
<li><a href= "[field:arcurl /]" title= "[field:fulltitle/]" >[field:fulltitle function = ' ( strlen("@me")>90 ? cn_substr("@me",90)."…" : "@me" )' /] </a></li> |