CodeIgniter Forums

Full Version: Best solution for up/down links
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]NiconPhantom[/eluser]
Hi all

I need move my menu elements up and down... What is the best solution for CI?

Thank you!

Alex

El Forum

[eluser]obiron2[/eluser]
you need to get the menu elements into a sorted array. The easiest way is to

store your menu elements in a database with a sort_order value
Code:
select * from menu_elements order by sort_order DESCENDING
This will get the elements into a object (or array depending on your RETURN)

pass this to the view:
Code:
$data['menu_elements'] = $Menu_elements
$this->load->view('my_view',$data)
In your view, loop through the elements and produce the menu labels
Code:
foreach ($menu_elements as $ME)
{
  print anchor($ME->targetURL,$ME->title). "BR"

}

El Forum

[eluser]JoostV[/eluser]
Not sure if this is what you mean, but I use a jQuery plugin for my CMS:
http://bitsinashortbit.wordpress.com/200...ry-plugin/

It creates a table of menu-items that can be dragged up and down. At the end of every drop I save the new order to the database.

So, no arrows or numbers, just drag the items to the right positions.

El Forum

[eluser]NiconPhantom[/eluser]
Thank you, thats very useful idea for me!


Alex