Dotclear

Changeset 2953:fdcac99dd62d


Ignore:
Timestamp:
02/01/15 12:40:09 (9 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add an ellipsis on short displayed entry content (with new tpl:EntryIfContentCut), closes #2015

Location:
inc/public
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inc/public/class.dc.template.php

    r2886 r2953  
    132132          $this->addBlock('EntriesFooter',array($this,'EntriesFooter')); 
    133133          $this->addBlock('EntriesHeader',array($this,'EntriesHeader')); 
    134           $this->addValue('EntryExcerpt',array($this,'EntryExcerpt')); 
    135134          $this->addValue('EntryAuthorCommonName',array($this,'EntryAuthorCommonName')); 
    136135          $this->addValue('EntryAuthorDisplayName',array($this,'EntryAuthorDisplayName')); 
     
    148147          $this->addValue('EntryContent',array($this,'EntryContent')); 
    149148          $this->addValue('EntryDate',array($this,'EntryDate')); 
     149          $this->addValue('EntryExcerpt',array($this,'EntryExcerpt')); 
    150150          $this->addValue('EntryFeedID',array($this,'EntryFeedID')); 
    151151          $this->addValue('EntryFirstImage',array($this,'EntryFirstImage')); 
    152152          $this->addValue('EntryID',array($this,'EntryID')); 
    153153          $this->addBlock('EntryIf',array($this,'EntryIf')); 
     154          $this->addBlock('EntryIfContentCut',array($this,'EntryIfContentCut')); 
    154155          $this->addValue('EntryIfFirst',array($this,'EntryIfFirst')); 
    155156          $this->addValue('EntryIfOdd',array($this,'EntryIfOdd')); 
     
    14341435 
    14351436     /*dtd 
    1436      <!ELEMENT tpl:EntryContent - O -- Entry content --> 
     1437     <!ELEMENT tpl:EntryContent - -- Entry content --> 
    14371438     <!ATTLIST tpl:EntryContent 
    14381439     absolute_urls  CDATA     #IMPLIED -- transforms local URLs to absolute one 
     
    14551456               return '<?php echo '.sprintf($f,'$_ctx->posts->getContent('.$urls.')').'; ?>'; 
    14561457          } 
     1458     } 
     1459 
     1460     /*dtd 
     1461     <!ELEMENT tpl:EntryIfContentCut - - -- Test if Entry content has been cut --> 
     1462     <!ATTLIST tpl:EntryIfContentCut 
     1463     absolute_urls  CDATA     #IMPLIED -- transforms local URLs to absolute one 
     1464     full           (1|0)     #IMPLIED -- test with full content and excerpt 
     1465     > 
     1466     */ 
     1467     public function EntryIfContentCut($attr,$content) 
     1468     { 
     1469          if (empty($attr['cut_string']) || !empty($attr['full'])) { 
     1470               return ''; 
     1471          } 
     1472 
     1473          $urls = '0'; 
     1474          if (!empty($attr['absolute_urls'])) { 
     1475               $urls = '1'; 
     1476          } 
     1477 
     1478          $short = $this->getFilters($attr); 
     1479          $cut = $attr['cut_string']; 
     1480          $attr['cut_string'] = 0; 
     1481          $full = $this->getFilters($attr); 
     1482          $attr['cut_string'] = $cut; 
     1483 
     1484          return '<?php if (strlen('.sprintf($full,'$_ctx->posts->getContent('.$urls.')').') > '. 
     1485               'strlen('.sprintf($short,'$_ctx->posts->getContent('.$urls.')').')) : ?>'. 
     1486               $content. 
     1487               '<?php endif; ?>'; 
    14571488     } 
    14581489 
  • inc/public/default-templates/currywurst/_entry-short.html

    r2625 r2953  
    2525               <p> 
    2626                    {{tpl:EntryContent encode_html="1" remove_html="1" cut_string="300"}} 
     27                    <tpl:EntryIfContentCut encode_html="1" remove_html="1" cut_string="300"> 
     28                         <span class="ellipsis">&nbsp;[&#8230;]</span> 
     29                    </tpl:EntryIfContentCut> 
    2730               </p> 
    2831          </div> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map