Error
  • The most recent request was denied because it contained an invalid security token. Please refresh the page and try again.
  • The most recent request was denied because it contained an invalid security token. Please refresh the page and try again.

Tue

14

Jul

2009

Drag 'n' Drop is here!

It’s been more than a week since I last updated you on my project that is dealing with increasing the frontend editing capability of Joomla! I’m excited to announce that this week I was able to implement Drag ‘n’ Drop placement of modules. In addition to that, I was able to fix some bugs and refine the code. You can download the latest release from JC -> http://joomlacode.org/gf/project/frediting/frs/

Here is a brief summary of how I’m implementing drag and drop for modules. For the JavaScript part, I’m using the Mootools Sortables class. To enable drag and drop for a particular position, you have to provide the container of the modules with the attribute ‘data-position’ in your template’s ‘index.php’. So, if, for example, you’ve a DIV that contains all the modules at the left position, then you’ll give it the attribute data-position=’left’. In most cases, the value of 'data-position' matches the value of the 'name' attribute of the jdoc:include statement. Here is a code example:

 
<div id="newsflash" data-position="newsflash">
 
<jdoc:include type="modules" name="newsflash" style="raw editor" />
 
</div>
 

The ‘data-’ type of attribute is supported in HTML 5. I might choose an alternative attribute, such as ‘rel’ or ‘alt’ but the idea of using a unique attribute is so that it does not interfere with the layout of any template. You can give this attribute to all DIV Containers for whose positions you want to enable Drag and Drop. So, for example, if you want to leave out the footer, simply don’t include the ‘data-position’ attribute in its container.

When you drag and drop the module into a new position and/or order, an AJAX request is sent to the method ‘saveOrder’ in the module controller. The controller method then saves the new position and/or order.

In addition to the demo, I have now set up my project at joomlacode.org so that you can help me find bugs. For now, the SVN source is still at labs. I’m in the process of moving my SVN repository to Joomla Code.

I might think about implementing editing of menu parameters if time permits. But, atleast for the following week, I’ll be fixing bugs and glitches in code as well as refining it and adding support for IE. I also have to start working on an administrative interface where you’ll be able to configure the behavior of the plugin, including setting the background-color on hover over titles, specifying unique classes for containers of article and page titles, etc.

Important Links

SVN Source: http://labs.joomla.org/svn/labs/playground/people/ankit
Bug Tracker: http://joomlacode.org/gf/project/frediting/tracker/
Latest Release: http://joomlacode.org/gf/project/frediting/frs/
Demo: http://ankitahuja.com/playground/joomla

51 Votes

19 Comments

Feed
  1. This is truly amazing! Something I've wanted for a really long time. Excellent work!
  2. Excellent. Time to give it a test run. Thanks.
  3. Just tried it and it works very well, though every time I refreshed the page I was given an error and the drag n drop feature moved a little slow. Can't wait for the final release so I can put this bad boy on my Web site!
  4. Nice Work.
    However, I keep getting an error alert message popping up saying that ¨The URL is not valid and cannot be loaded¨
  5. Tim, dk: The alert message is a problem with the Joomla! installation on my server. Nothing to do with my project because it'll work perfectly fine on your local installation.
    I'm just a little lazy to set up the demo all over again.
  6. WOW this is amazing!!! :D Thanks for this
  7. This is SO needed. The more I can keep customers out of the backend, the cheaper support becomes. That's the killer with Joomla right now, customer support.
  8. The July template from Rockettheme called "Affinity" has already implemented this. At least I'm assuming they are doing it the same way.
  9. Cool...

    ...nothing more is needed.
  10. Ok. I'm impressed :)

    Should this work with a any module in any position or is it limited to moving modules assigned to the same position?
  11. Fantastic! Can this make it into 1.6?

    The one thing I noticed is that I couldn't drag a module into a position unless it already had at least one module in it.
  12. Pretty nice, works well. I was wondering if I took all the modules out of one spot if it would remove it, and upon refresh it did, but then you have the problem that you cant put anything back in the removed spot, be interesting to see how you get around this, if at all.
  13. Combine this with collapsable modules and saving of positions and you've got yourself a BBC.com-style personalised homepage - something we could do with J!1.0 but not since, that I know of.. :-D
  14. Hi it is my first time visiting here, it’s a great site with a great articles, thanks for share.
  15. This is really cool. Thanks for your work.
  16. Brian: I'm not sure how they are implementing it. But, mine should work with any template whereas their's is restricted to that particular template.

    guysmiley: It should work with any module in any position.

    unleash.it, AaronF: I think I'll give this a thought and see if I'm able to come up with something.
  17. Wow!! This is just very really really COOL!! Keep up the good work!
  18. Ok, this one indeed a nice one. My complements. I`m trying to implement drag-and-drop for front-end and came to same concussion: plugin + module chrome are the best solution.
  19. Great web site. Solid, helpful advice that you can benefit from and for free, it does not get much better than that. The web needs more sites like this one, please keep it up.

Add Comment


    • >:o
    • :-[
    • :'(
    • :-(
    • :-D
    • :-*
    • :-)
    • :P
    • :\
    • 8-)
    • ;-)