我需要动态更改标签容器中tab的子计数。
我的要求, 我创建了一个类似的小部件,它将标题显示为Like(2)
当我点击相似小部件中的按钮时,我需要将子计数更新为3。
类Core_Widget_LikesController扩展 Engine_Content_Widget_Abstract {protected $ _childCount;上市 function indexAction(){ //获得主题 $ subject = null; if(Engine_Api :: _() - > core() - > hasSubject()){ $ subject = Engine_Api :: _() - > core() - > getSubject(); } else if(($ subject = $ this-> getParam(' subject'))){ list($ type,$ id)= explode(' ',$ subject); $ subject = Engine_Api :: _() - > getItem($ type,$ id); } else if(($ type = $ this-> _getParam(' type'))&& ($ id = $ this-> _getParam(' id'))){ $ subject = Engine_Api :: _() - > getItem($ type,$ id); }
if( !($subject instanceof Core_Model_Item_Abstract) || !$subject->getIdentity() || (!method_exists($subject, 'comments') && !method_exists($subject, 'likes')) ) { return $this->setNoRender(); } // Perms $viewer = Engine_Api::_()->user()->getViewer(); $this->view->canComment = $canComment = $subject->authorization()->isAllowed($viewer, 'comment'); $this->view->canDelete = $canDelete = $subject->authorization()->isAllowed($viewer, 'edit'); // Likes $this->view->viewAllLikes = $this->_getParam('viewAllLikes', false); $this->view->likes = $likes = $subject->likes()->getLikePaginator(); // Comments // If has a page, display oldest to newest if( null !== ( $page = $this->_getParam('page')) ) { $commentSelect = $subject->comments()->getCommentSelect(); $commentSelect->order('comment_id ASC'); $comments = Zend_Paginator::factory($commentSelect); $comments->setCurrentPageNumber($page); $comments->setItemCountPerPage(10); $this->view->comments = $comments; $this->view->page = $page; } else { // If not has a page, show the $commentSelect = $subject->comments()->getCommentSelect(); $commentSelect->order('comment_id DESC'); $comments = Zend_Paginator::factory($commentSelect); $comments->setCurrentPageNumber(1); $comments->setItemCountPerPage(4); $this->view->comments = $comments; $this->view->page = $page; } if( $viewer->getIdentity() && $canComment ) { $this->view->form = $form = new Core_Form_Comment_Create(); //$form->setAction($this->view->url(array('action' => ''))) $form->populate(array( 'identity' => $subject->getIdentity(), 'type' => $subject->getType(), )); } // Hide if can't post and no comments if( !$canComment && !$canDelete && count($comments) <= 0 && count($likes) <= 0 ) { $this->setNoRender(); } $this->_childCount = $likes->getTotalItemCount(); }
public function getChildCount(){ 返回$ this-&gt; _childCount; }}