2017-05-24 5 views

답변

0

좋아요.이 경우 간단한 ViewHelper를 만듭니다. 나는 당신이 수천의 게시물을 갖고 있지만 수백이 아니라면 모두 괜찮을 것입니다. 는 먼저 우리는

<?php 

namespace HIT\huskytheme\ViewHelpers\News; 

class CountCommnetsViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper { 

    /** 
    * @var \DRCSystems\NewsComment\Domain\Repository\CommentRepository 
    * @inject 
    */ 
    protected $commentRepository = null; 

    /** 
    * 
    * @param int $news 
    * @return string 
    */ 
    public function render($news) { 
     return count($this->commentRepository->getCommentsByNews($news)); 
    } 

} 

공급 업체 이름과 ViewHelper 위치를 '공간'을 변경하시기 바랍니다 우리의 프로젝트 EXT에 ViewHelper를 추가 nned.

그런 다음 tx_news fluid 템플릿을 어딘가에 복사하고 TS로 추가하십시오. 템플릿 -> Partitials-> - 온라인> Item.html (또는 경로)에서 당신이 ViewHelper를 호출 할 수 있습니다, 그와 같은 사용

{namespace s=HIT\huskytheme\ViewHelpers} 
... 
Comments: ({s:news.countCommnets(news: newsItem.uid)}) 

또는 다른 템플릿 - 단지 내부 corect newsItem.uid을 추가하고 namesapce을 소유 againe 돛대라고 부를 수 있습니다.