Welcome Guest, Not a member yet? Register   Sign In
Menu order Up or Down
#1

[eluser]Unknown[/eluser]
Hi!

I'm very new to Codeigniter and PHP. But I am right now trying to make menu fully dynamic so that my client can change title, url and order on the site menu.

I can't find any help or anything on how to change the menu order (+1 or -1). It would be very nice if you could help me with this.

I do have a database with a "order" column. Wich I place the orderID in.

Would be very kind if you could help me. Thanks!
#2

[eluser]csotelo[/eluser]
I would use jQuery UI sortable library:

http://jqueryui.com/demos/sortable/#default

And when you click a button, get an array with the order of items, which will be updated in your BD.
#3

[eluser]Unknown[/eluser]
Thanks csotelo!

That's really nice. But the I wonder (As told before, I'm not a PHP guru) how I post this in to the database.

My structure looks like this

Code:
CREATE TABLE `dyn_menu` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `link_type` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'uri',
  `page_id` int(11) NOT NULL DEFAULT '0',
  `module_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'http://www.example.com/folder/index.php/show/',
  `uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `dyn_group_id` int(11) NOT NULL DEFAULT '0',
  `position` int(5) NOT NULL DEFAULT '0',
  `target` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `parent_id` int(11) NOT NULL DEFAULT '0',
  `is_parent` tinyint(1) NOT NULL DEFAULT '0',
  `show_menu` enum('0','1') COLLATE utf8_unicode_ci NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `dyn_group_id - normal` (`dyn_group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

The 'position' is the order of the menu. And the 'parent_id' is the id of the 'page_id'. It tells if the link is parent or not. If not the value is 0.

Sorry if this is a stupid question.
#4

[eluser]csotelo[/eluser]
Hello, the question is not stupid, on the contrary, the issue is complex. Since you need to put together a menu and indefinitely or multilevel submenus, which can be repositioned.

What I showed you only part of UI to be as friendly as possible. What you show in your CMS is something like this:

http://boagworld.com/demos/sitemap/

Now, the internal issue is complex and involving the logic of PHP and MySql. You need to check the topic of nested and/or hierarchical records.

You can see the topic here:

http://ellislab.com/forums/viewthread/57707/

And I hope someone with more experience will provide some library in CI 2 to handle these types of records.




Theme © iAndrew 2016 - Forum software by © MyBB