//First you go to in database create new field "show_menu" in cms_page table.
//After that go in app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/main.php file and put thi code to add a fieled in admin page
//First find this code
<?php
$fieldset->addField('identifier', 'text', array(
'name' => 'identifier',
'label' => Mage::helper('cms')->__('URL Key'),
'title' => Mage::helper('cms')->__('URL Key'),
'required' => true,
'class' => 'validate-identifier',
'note' => Mage::helper('cms')->__('Relative to Website Base URL'),
'disabled' => $isElementDisabled
));
?>
//after these code paste below code
<?php
$fieldset->addField('sort_order', 'text', array(
'name' => 'sort_order',
'label' => Mage::helper('cms')->__('Page Order'),
'title' => Mage::helper('cms')->__('Page Order'),
'required' => false,
));
$fieldset->addField('show_menu', 'select', array(
'label' => Mage::helper('cms')->__('Show on top menu'),
'title' => Mage::helper('cms')->__('Show on top menu'),
'name' => 'show_menu',
'required' => true,
'options' => $model->getAvailableStatuses(),
'disabled' => $isElementDisabled,
));
?>
To show on cms->page manage page insert these code in app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php
<?php
//First find this code
$this->addColumn('is_active', array(
'header' => Mage::helper('cms')->__('Status'),
'index' => 'is_active',
'type' => 'options',
'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
));
////after these code paste below code
$this->addColumn('sort_order', array(
'header' => Mage::helper('cms')->__('Page Order'),
'index' => 'sort_order',
'type' => 'text',
));
$this->addColumn('show_menu', array(
'header' => Mage::helper('cms')->__('Show on top menu'),
'index' => 'show_menu',
'type' => 'options',
'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
));
?>
and last you go to app/design/frontend/default/bestcase/template/page/html/topmenu.phtml
and put these code
<?php $cms_pages = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?>
<?php $cms_pages->getSelect()->where('show_menu = 1')->order('sort_order ASC');
foreach($cms_pages as $_page)
{
$data = $_page->getData();
$pagestatus = $data['show_menu'];
if($pagestatus=="1"){
?>
<li><a href="<?php echo $this->getUrl($data['identifier']) ?>"><?php echo $data['title'];?> </a></li>
<?php
}
}
?>
set up the page to show on top menu go to cms->page and add 1 in Show on top menu field click on save page.
//After that go in app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/main.php file and put thi code to add a fieled in admin page
//First find this code
<?php
$fieldset->addField('identifier', 'text', array(
'name' => 'identifier',
'label' => Mage::helper('cms')->__('URL Key'),
'title' => Mage::helper('cms')->__('URL Key'),
'required' => true,
'class' => 'validate-identifier',
'note' => Mage::helper('cms')->__('Relative to Website Base URL'),
'disabled' => $isElementDisabled
));
?>
//after these code paste below code
<?php
$fieldset->addField('sort_order', 'text', array(
'name' => 'sort_order',
'label' => Mage::helper('cms')->__('Page Order'),
'title' => Mage::helper('cms')->__('Page Order'),
'required' => false,
));
$fieldset->addField('show_menu', 'select', array(
'label' => Mage::helper('cms')->__('Show on top menu'),
'title' => Mage::helper('cms')->__('Show on top menu'),
'name' => 'show_menu',
'required' => true,
'options' => $model->getAvailableStatuses(),
'disabled' => $isElementDisabled,
));
?>
To show on cms->page manage page insert these code in app/code/core/Mage/Adminhtml/Block/Cms/Page/Grid.php
<?php
//First find this code
$this->addColumn('is_active', array(
'header' => Mage::helper('cms')->__('Status'),
'index' => 'is_active',
'type' => 'options',
'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
));
////after these code paste below code
$this->addColumn('sort_order', array(
'header' => Mage::helper('cms')->__('Page Order'),
'index' => 'sort_order',
'type' => 'text',
));
$this->addColumn('show_menu', array(
'header' => Mage::helper('cms')->__('Show on top menu'),
'index' => 'show_menu',
'type' => 'options',
'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
));
?>
and last you go to app/design/frontend/default/bestcase/template/page/html/topmenu.phtml
and put these code
<?php $cms_pages = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?>
<?php $cms_pages->getSelect()->where('show_menu = 1')->order('sort_order ASC');
foreach($cms_pages as $_page)
{
$data = $_page->getData();
$pagestatus = $data['show_menu'];
if($pagestatus=="1"){
?>
<li><a href="<?php echo $this->getUrl($data['identifier']) ?>"><?php echo $data['title'];?> </a></li>
<?php
}
}
?>
set up the page to show on top menu go to cms->page and add 1 in Show on top menu field click on save page.
No comments:
Post a Comment