I set up a simple menu system that allows users to add menu items on the site.
Came across a design issue with determining the main landing page, deleting the breadcrumbs, and if it is active or not.
The only solutions I can think up are hacks, any suggestions? Seems like some of the guys on here who have spent time developing a Yii CMS could point me in the right direction.
Here is my index action on my SiteController:
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->order = 'isLandingPage DESC, ordering ASC, id DESC';
$menuItem = MenuItem::model()->find($criteria);
$page = $menuItem->page;
if ($page != null)
{
$clientScript = Yii::app()->clientScript;
$clientScript->registerMetaTag($page->description, 'description');
$clientScript->registerMetaTag($page->keywords, 'keywords');
$this->render('/page/view', array('model' => $page));
}
else
{
$this->redirect(array($menuItem->url));
}
}
here is my layout:
<div id="mainmenu">
<?php
$menuItems = MenuItem::model()->ordered()->findAll();
$items = array();
foreach ($menuItems as $menuItem)
{
$items[] = $menuItem->toMenuItem();
}
?>
<?php $this->widget('zii.widgets.CMenu',array('items'=>$items)); ?>
</div><!-- mainmenu -->
<?php $this->widget('zii.widgets.CBreadcrumbs', array(
'links'=>$this->breadcrumbs,
)); ?><!-- breadcrumbs -->
<?php echo $content; ?>