magento--------------输出content前字符过滤处理,现在字母个数处理

    技术2022-05-13  8

    1.    public function getContent($limit = 0)     {         //process page         $helper = Mage::helper('cms');         $processor = $helper->getPageTemplateProcessor();         $html = $processor->filter($this->getData("content"));         if($limit)             return $this->html_cut_text($this->strip_html_tags($html), $limit);         else                return ($html);     }     2. //是一个过滤函数。 $processor = $helper->getPageTemplateProcessor(); $html = $processor->filter($this->getData("content")); 2.1  public function getPageTemplateProcessor()     {         $model = (string)Mage::getConfig()->getNode(self::XML_NODE_PAGE_TEMPLATE_FILTER);         return Mage::getModel($model);     } 2.1.1 const XML_NODE_PAGE_TEMPLATE_FILTER     = 'global/cms/page/tempate_filter'; 2.1.2 <global>   <cms>        <page>           <tempate_filter>cms/template_filter</tempate_filter>        </page>   </cms> </global> //故Mage::getModel($model)得到的是Mage/cms/model/template/filter.php 3. //处理内容,如果$limit为100,则抓取前面100个字母,用于简介等内容实用 return $this->html_cut_text($this->strip_html_tags($html), $limit);


    最新回复(0)