简体   繁体   English

如何获取基于magento中特定主题的cms页面列表?

[英]How to get list of cms pages based on a particular theme in magento?

I have created cms pages for two themes of a single store view. 我已经为单个商店视图的两个主题创建了cms页面。
I want to show all the cms pages links in the front end which is specific to the theme. 我想在前端显示特定于主题的所有cms页面链接。
ie only those cms page links should come which is used in a particular theme. 即只有那些在特定主题中使用的cms页面链接应该出现。
I have used below function to extract all the cms pages.. 我已经使用下面的功能来提取所有的CMS页面。

public function getCMSPages(){

$storeId = $this->helper('core')->getStoreId();
$cms = Mage::getModel('cms/page')->getCollection()
                ->addFieldToFilter('is_active',1)
                ->addStoreFilter($storeId);
$url = Mage::getBaseUrl();
$html = "";
foreach($cms as $cmspage):
    $page = $cmspage->getData();    
    if($page['identifier'] == "no-route" || $page['identifier'] == "enable-cookies" || $page['identifier'] == "empty"){
         /* do nothing */
     } else {
        if($page['identifier'] == "home"){
            $html .= "<li><a href=\"$url\" title=\"".$page['title']."\">".$page['title']."</a></li>\n";
        } else {
            $html .= "<li><a href=\"$url".$page['identifier']."\" title=\"".$page['title']."\">".$page['title']."</a></li>\n";
        }
    }
endforeach;

return $html;   
}   

How can I get cms pages only for a particular theme ? 我如何才能仅针对特定主题获取cms页面

you can add theme filter custom_theme on this field 您可以在此字段上添加主题过滤器custom_theme

$storeId = $this->helper('core')->getStoreId();
$cms = Mage::getModel('cms/page')->getCollection()
                ->addFieldToFilter('is_active',1)
                ->addFieldToFilter('custom_theme','default/default')
                ->addStoreFilter($storeId);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM