CodeIgniter Forums
Best solution for up/down links - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Best solution for up/down links (/thread-15734.html)



Best solution for up/down links - El Forum - 02-13-2009

[eluser]NiconPhantom[/eluser]
Hi all

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

Thank you!

Alex


Best solution for up/down links - El Forum - 02-16-2009

[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"

}



Best solution for up/down links - El Forum - 02-16-2009

[eluser]JoostV[/eluser]
Not sure if this is what you mean, but I use a jQuery plugin for my CMS:
http://bitsinashortbit.wordpress.com/2007/07/22/nested-sortable-jquery-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.


Best solution for up/down links - El Forum - 02-16-2009

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


Alex