[EXTENSION] NordCms

Any chance of adding a sub menu functionality to the CMS Menu?

I tried modifying the database tables by:

1- Adding a parent_menu_item_id to the cms_menu table.

2- Adding a child_menu_id to the cms_menu_item table.

But not able to render them properly.

I would like to have




<ul id="main-menu">

  <li>

     <ul id="item1-sub-menu>

        <li>...</li>

     </ul>

  </li>

  <li>...</li>

</ul>



Greetings!

I’m trying to use this module but, when i paste the code used to create a new node, in the default ‘about.php’, that comes with new web apps




<?php

/* @var $this SiteController */


$this->pageTitle=Yii::app()->name . ' - About';

$this->breadcrumbs=array(

	'About',

);

Yii::app()->cms->createUrl('foo');

?>

<h1>About</h1>


<p>This is a "static" page. You may change the content of this page

by updating the file <code><?php echo __FILE__; ?></code>.</p>



i get the following error:




Fatal error: Maximum function nesting level of '100' reached, aborting! in /var/www/yii-1.1.13.e9e4a0/framework/logging/CLogger.php on line 96


Call Stack:

    0.0001     646152   1. {main}() /var/www/MyVMC/index.php:0

    0.0089    3136752   2. CApplication->run() /var/www/MyVMC/index.php:13

    0.0089    3138088   3. CWebApplication->processRequest() /var/www/yii-1.1.13.e9e4a0/framework/base/CApplication.php:169

    0.0120    3467304   4. CWebApplication->runController() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:141

    0.0142    4091984   5. CController->run() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:282

    0.0151    4192560   6. CController->runActionWithFilters() /var/www/yii-1.1.13.e9e4a0/framework/web/CController.php:265

    0.0151    4192560   7. CController->runAction() /var/www/yii-1.1.13.e9e4a0/framework/web/CController.php:286

    0.0151    4192560   8. CAction->runWithParams() /var/www/yii-1.1.13.e9e4a0/framework/web/CController.php:308

    0.0151    4193984   9. CViewAction->run() /var/www/yii-1.1.13.e9e4a0/framework/web/actions/CAction.php:76

    0.0154    4195408  10. CController->render() /var/www/yii-1.1.13.e9e4a0/framework/web/actions/CViewAction.php:140

    0.0154    4195648  11. CController->renderPartial() /var/www/yii-1.1.13.e9e4a0/framework/web/CController.php:782

    0.0155    4195992  12. CBaseController->renderFile() /var/www/yii-1.1.13.e9e4a0/framework/web/CController.php:869

    0.0156    4196152  13. CBaseController->renderInternal() /var/www/yii-1.1.13.e9e4a0/framework/web/CBaseController.php:95

    0.0156    4243648  14. require('/var/www/MyVMC/protected/views/site/pages/about.php') /var/www/yii-1.1.13.e9e4a0/framework/web/CBaseController.php:126

    0.0157    4245200  15. CModule->__get() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:0

    0.0157    4245200  16. CModule->getComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:103

    0.0160    4249696  17. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:386

    0.0160    4250088  18. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0161    4250384  19. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0161    4250680  20. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0161    4250680  21. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0163    4254096  22. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0164    4254488  23. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0164    4254784  24. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0164    4255080  25. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0164    4255080  26. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0167    4259056  27. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0167    4259448  28. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0167    4259744  29. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0168    4260040  30. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0168    4260040  31. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0171    4264016  32. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0171    4264408  33. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0171    4264704  34. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0171    4265000  35. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0171    4265000  36. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0175    4268976  37. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0175    4269368  38. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0175    4269664  39. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0175    4269960  40. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0175    4269960  41. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0179    4274000  42. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0179    4274392  43. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0179    4274688  44. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0179    4274984  45. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0180    4274984  46. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0183    4278960  47. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0183    4279352  48. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0184    4279648  49. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0184    4279944  50. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0184    4279944  51. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0189    4283920  52. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0189    4284312  53. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0190    4284608  54. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0190    4284904  55. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0190    4284904  56. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0194    4288880  57. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0194    4289272  58. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0195    4289568  59. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0195    4289864  60. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0195    4289864  61. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0203    4293840  62. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0203    4294232  63. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0203    4294528  64. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0203    4294824  65. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0203    4294824  66. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0208    4298800  67. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0208    4299192  68. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0209    4299488  69. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0209    4299784  70. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0209    4299784  71. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0214    4303760  72. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0214    4304152  73. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0215    4304448  74. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0215    4304744  75. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0215    4304744  76. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0221    4308720  77. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0221    4309112  78. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0221    4309408  79. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0221    4309704  80. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0221    4309704  81. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0227    4313808  82. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0228    4314200  83. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0228    4314496  84. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0228    4314792  85. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0228    4314792  86. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0235    4318768  87. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0235    4319160  88. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0235    4319456  89. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0235    4319752  90. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0235    4319752  91. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0242    4323728  92. YiiBase::createComponent() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:282

    0.0242    4324120  93. YiiBase::import() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:196

    0.0243    4324416  94. YiiBase::getPathOfAlias() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:307

    0.0243    4324712  95. CWebApplication->findModule() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:363

    0.0243    4324712  96. CModule->getModule() /var/www/yii-1.1.13.e9e4a0/framework/web/CWebApplication.php:533

    0.0243    4325016  97. YiiBase::trace() /var/www/yii-1.1.13.e9e4a0/framework/base/CModule.php:278

    0.0243    4325152  98. YiiBase::log() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:446

    0.0249    4567472  99. CLogger->log() /var/www/yii-1.1.13.e9e4a0/framework/YiiBase.php:476



My configuration, in the main.php is the following:




<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Web Application',


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

		'application.modules.cms.CmsModule',

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'***',

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

		'cms'=>array(

		    'class'=>'cms.components.Cms',

		    // the names of the web users with access to the cms

		    'users'=>array('admin'),

		    // the langauges enabled for the cms

		    'languages'=>array('en_us'=>'English'),

		    // the default language

		    'defaultLanguage'=>'en_us',

		    // the types of files that can uploaded as attachments

		    'allowedFileTypes'=>'jpg, gif, png',

		    // the maximum allowed filesize for attachments

		    'allowedFileSize'=>1024,

		    // the path to save the attachments

		    'attachmentPath'=>'/files/cms/attachments/',

		    // the template to use for node headings

		    'headingTemplate'=>'<h1 class="heading">{heading}</h1>',

		    // the template to use for widget headings

		    'widgetHeadingTemplate'=>'<h3 class="heading">{heading}</h3>',

		    // the template to use for page titles

		    'pageTitleTemplate'=>'{title} | {appName}',

		    // the application layout to use with the cms

		    'appLayout'=>'application.views.layouts.main',

		    // the name of the error flash message categories

		    'flashError'=>'error',

		    'flashInfo'=>'info',

		    'flashSuccess'=>'success',

		    'flashWarning'=>'warning',

		),

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

		// uncomment the following to enable URLs in path-format

		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				/*

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

				*/

				'page/<name>-<id:\d+>.html'=>'cms/node/page',

			),

		),

		'cms'=>array(

			'class'=>'cms.components.Cms'

		),

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=***',

			'emulatePrepare' => true,

			'username' => '***',

			'password' => '***',

			'charset' => 'utf8',

		),

		'errorHandler'=>array(

			// use 'site/error' action to display errors

			'errorAction'=>'site/error',

		),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

);



Any idea with what’s going on???

This is a good. I tried to get the submenu functionality to it. I added a field to make each menu to be a submenu in itself. Is there a better way to do it?


Alter table cms_table_item add submenu varchar(255) after url

I did the required changes to the model CmsMenuItem.php. Following functions were changed


public function rules() { 

 return array( 

 array('menuId, locale, label, url, weight', 'required'), 

 array('menuId, weight, visible', 'numerical', 'integerOnly'=>true), 

 array('menuId', 'length', 'max'=>10), 

 array('locale', 'length', 'max'=>50), 

 array('label, url, submenu', 'length', 'max'=>255), 

 array('id, menuId, label, url, visible', 'safe', 'on'=>'search'), 

 ); 

 } 

 

 public function attributeLabels() { 

 return array( 

 'id' => '#', 

 'menuId' => Yii::t('CmsModule.core', 'Menu'), 

 'label' => Yii::t('CmsModule.core', 'Label'), 

 'url' => Yii::t('CmsModule.core', 'URL'), 

 'submenu' => Yii::t('CmsModule.core', 'Sub-menu'), 

 'weight' => Yii::t('CmsModule.core', 'Weight'), 

 'visible' => Yii::t('CmsModule.core', 'Visible'), ); 

 } 


 public function createConfig() { 

 $config = array(); 


 if ($this->visible) { 

 $visible = true; 

 if (strpos($this->url, 'http') !== false) 

 $url = $this->url; 

 else if (strpos($this->url, '/') !== false) 

 $url = array($this->url); 

 else { 

 /** @var Cms $cms */ 

 $cms = Yii::app()->cms; 

 $name = $this->url; 

 $page = $cms->loadPage($name); 


 // Ensure that we don't like to unpublished pages. 

 if (!$page->published) 

 $visible = false; 


 $url = $cms->createUrl($name); 

 $active = $cms->isActive($name); 

 } 


 if (isset($url)) { 

 $config['label'] = $this->label; 

 $config['url'] = $url; 

 $config['visible'] = $visible; 

 

 if (isset($active)) 

 $config['active'] = $active; 

 } 


 if($this->submenu != "") { 

 $config['items'] = array(); 

 $model = CmsMenu::model()->find('name = :name', array(':name' => $this->submenu)); 

 $config['items'] = CMap::mergeArray($model->createItems(), $config['items']); 

 } 

 } 


 return $config; 

} 

That largely did it.

Now that for each menu item, we have a submenu. Any menu system name can be used to appear as submenu for a menu item. I now needed the admin form for menu item to show submenu field as well

cms/views/menuItem/_form.php


echo $form->textFieldRow($model,'submenu');

Now, whenever the menu widget is called, submenu will also get rendered. Hope this help someone.

Hi, Chris! You create great extension! But now it is inconsistent with latest versions of Yii-Bootrap or Yii-Booster. It relies on bootstrap.widgets.BootGridView which can’t be found, so I replaced it with bootstrap.widgets.TbGridView and it works.

This issue is common for stable, current and v2 branches. So, I am slightly confused. Which branch I have fork to contribute. I want to contribute into new version ( v2 of NordCms ) how can I do this. Are you going to share it?

Anyway, thank you for awesome extensions.

It looks like the newest fork/branch is this: https://bitbucket.org/Crisu83/nordcms

But it’s quite broken and it requires a lot of fixing.

There’s also something here: https://github.com/Crisu83/yii-cms

But it looks like a draft.

CMS Yii-Booster Integration

If anyone is interested I have attached some updated bootstrap theme files for CMS v0.9.0 to work with Yii-Booster 4.0.1 but it should work with 3.1.1 also.

Ive got it using CKEditor from Yii-Booster instead of MarkItUp so you have a high quality WYSIWYG editor, CKEditor has been set to use bootstrap.min.css from Yii-Booster and your themes css/main.css file, this makes the content in the editor look closer to how it will on the page. Also have split the update page into multiple tabs a bit like NordCMS v2 has.

Just extract the archive into the views folder of your theme (themes/mytheme/views) and they will take over from the standard CMS layout files. Yii-Booster is required for these to work.

Let me know if you have any issues.

Execuse me.

I have extract last version. Then:

‘page/<name>-<id:\d+>.html’=>‘cms/node/page’

And wrote on view:

Yii::app()->cms->createUrl(‘foo’);

I see in table “cms_node” new record with id = 1. But can’t open link site.dev/page/foo-1.html.

What did i miss?

Hello,

do you have any plans to update the NordCMS for Yii 2.0 ?

Thanks.