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

来源:互联网 发布:windows nt 6.2 编辑:程序博客网 时间:2024/06/04 18:20




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);