Ejemplo n.º 1
0
 public function getPostShortContent($post, $storeId = 0)
 {
     $content = $post->getPostContent();
     $isUseShortContent = Mage::getStoreConfig(Magentothem_Blog_Helper_Config::XML_BLOG_USESHORTCONTENT, $storeId);
     if ($isUseShortContent && trim($post->getShortContent())) {
         $content = trim($post->getShortContent());
     } elseif ((int) Mage::getStoreConfig(Magentothem_Blog_Helper_Config::XML_BLOG_READMORE, $storeId)) {
         $strManager = new Magentothem_Blog_Helper_Substring(array('input' => Mage::helper('blog')->filterWYS($post->getPostContent())));
         $content = $strManager->getHtmlSubstr((int) Mage::getStoreConfig(Magentothem_Blog_Helper_Config::XML_BLOG_READMORE));
     }
     return $content;
 }
Ejemplo n.º 2
0
 protected function _processCollection($collection, $category = false)
 {
     /* add category to url */
     $categoryUrl = self::$_helper->isCategoryUrl();
     /* use short content for posts */
     $shortContent = self::$_helper->useShortContent();
     /* readMoreCount */
     $readMoreCount = (int) self::$_helper->readMoreCount();
     /* cache (run-time) all categories related to products */
     $this->_prepareRelatedCategories($collection);
     foreach ($collection as $item) {
         $this->_prepareData($item)->_prepareDates($item);
         /* prepare urls depnding on mode */
         if ($category && $categoryUrl) {
             $item->setAddress($this->getBlogUrl(null, array(self::$_catUriParam => $category->getIdentifier(), self::$_postUriParam => $item->getIdentifier())));
         } else {
             $item->setAddress($this->getBlogUrl($item->getIdentifier()));
         }
         /* prepare short content fields */
         if ($shortContent) {
             if ($item->getShortContent()) {
                 $item->setPostContent($item->getShortContent() . $this->_getReadMoreLink($item));
             }
         } elseif ($readMoreCount) {
             $strManager = new Magentothem_Blog_Helper_Substring(array('input' => self::$_helper->filterWYS($item->getPostContent())));
             $content = $strManager->getHtmlSubstr($readMoreCount);
             if ($strManager->getSymbolsCount() == $readMoreCount) {
                 $content .= $this->_getReadMoreLink($item);
             }
             $item->setPostContent($content);
         }
         /* add categories the item is related to */
         $this->_addCategories($item);
     }
     return $collection;
 }