Project:Jquery Drag Drop Blocks
Version:6.x-1.0
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Is there a way to save the dragged-dropped position per user? As you know, when you go to a new page (or refresh) the positioning is lost.
Thanks!

Comments

#1

+1

#2

Cool to play with, but serves no function.

This module needs a save position button and a permissions settings page.

Thanks for starting this module.

#3

Haha indeed, its just a useless thing right now.

#4

Yeah its just to play around. jQuery doesn't save when u refresh the page

#5

+1

#6

Iv just tried to make the save settings thing to work..

Just place the following code after line number 79 in jquery_drag_drop.module

$.post("$base_url/blocksave.php?blockinfo="+serial.hash, {queryString: ""+serial.hash+""}, function(data){

        $('#suggestions').show();
$('#autoSuggestionsList').html(data);

});

After this make a php file in the root directory with name blocksave.php and put the following code in it..

<?php

/* Creater Ebizontek.
* Himanshu=>himanshu@ebizontek.com
* To save the block Position once the drag and drop functionality
* occurs on mynuzcom page.
*/


require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global
$user, $base_url;





print
"<div style='clear:both'></div>";
$getdata = $_POST['queryString'];               

//Update User's Block info once page is loaded

$userconfig = db_query("SELECT * FROM {drop_block_info} WHERE uid = %d",$user->uid);
while(
$uc = db_fetch_object($userconfig)){
   
db_query("UPDATE {blocks} SET region = '%s' WHERE module = '%s' AND delta = '%s'", $uc->region , $uc->module , $uc->delta);

}

print
"The Getdata is here<br />";
print_r($getdata);
print
"<br />";

$b1 = explode('&', $getdata); 
print
"The break b1(GETDATA):"."<pre>";            //'&' Break
print_r($b1);
print
"</pre>";


foreach(
$b1 as $id=>$key){

    print
"<br /><br />The Process For Block-".$id."<br /><br />";
    print
"For loop-".$id."<pre>";
   
$b2a = explode('=', $b1[$id]);
   
print_r($b2a);
    print
"</pre>";


   
$b2a0 = explode('-', $b2a[0]);                // '-' Break
   
print " The break b2a0:"."<pre>";
   
print_r($b2a0);
    print
"</pre>";

   
$b2a0a = explode('[', $b2a0[1]);            // Break to get region
   
print " The break b2a0a:"."<pre>";
   
print_r($b2a0a);
    print
"</pre>";

   
$b2a01 = explode('-', $b2a[1]);                //Break to get nid
   
print " The break b2a01:"."<pre>";
   
print_r($b2a01);
    print
"</pre>";

   
$module = $b2a01[1];
   
$delta = $b2a01[2];
   
$getregion = $b2a0a[0];
   
$region = "mynuzcom_".$getregion;
   
$weight = 0;
   
$useruid = user_load(array("uid"=>arg(1)));
   
$uid = $useruid->uid;
   
$bid = db_result(db_query("SELECT bid FROM {blocks} WHERE module = '%s' AND delta = %d", $module , $delta));

    print
"The Block Delta is".$delta."<br />";
    print
"The New Region is: ".$region."<br />";
    print
"The Block bid is: ".$bid."<br />";
    print
"The module is: ".$module."<br />";

   

   
$bidexist = db_result(db_query("SELECT bid FROM {drop_block_info} WHERE bid = %d AND uid = %d",$bid,$uid));
    if(
$bidexist){
       
db_query("UPDATE {drop_block_info} SET region = '%s' , uid = %d WHERE bid = %d", $region , $uid , $bidexist);
    }else{
       
db_query("INSERT INTO {drop_block_info} (bid, region , delta , weight , uid , module) VALUES (%d , '%s' , %d , %d , %d , '%s' )",$bid , $region , $delta , $weight , $uid , $module );
    }
   
   
db_query("UPDATE {blocks} SET region = '%s',status = %d , visibility = %d , cache = %d WHERE module = '%s' AND delta = '%s'", $region , 1 , 1 , -1 , $module , $delta);


    }

unset (
$module);
unset (
$delta);
unset (
$getregion);
unset (
$region);
unset (
$weight);
unset (
$uid);
unset (
$bid);
unset (
$bidexist);

?>

Create a new table { drop_block_info } in the database with Following fields:

1 dragid (Primary Auto Increment)
2 bid
3 module (varchar)
4 region (varchar)
5 delta (integer)
6 weight (tiny int)
7 uid (int)

This should work fine now...

P:S :- Its just a temporary implementation for my use..
You'll have to customize it to suit you.

Himanshu
Ebizontek.

#7

Thanks a lot!
But when I paste your code --- module refuses to work :(((
I've created table in my DB and after several tests it was empty...
What this may be?
I think PHP-file works fine, but pathch in MODULE-file fails.
I don't know AJAX well, so i can't solve it. May be you can publish your new MODULE-file???

#8

Not sure if I should make my own topic, but here works I guess.

is the module still working on this?

If so, I sorta made a module similar to this, want to try and combine?

It also drags, drops, saves the settings per users / anonymous user session id (doesn't effect drupal block configuration) with per region / block/ theme ID/selector configuration. Major difference is it's not using slider or anything and just at top of region atm. Needs some cleaning up, but here's a demo : http://demo.intheclosets.com/node/1 .

Additional extras include collapsible body that saves like the drag does and removing block if block can be removed by user (uses drupal core block remove per user. )

#9

This is a great demo.
If it is possible to combine your module with the region_manager module. In this way you can use the drag and drop feature as a design instrument in drupal block configuration.

Because drupal blocks are region specific and you cant duplicate blocks, dragging blocks to different regions will cause a night mare.
But if you use the region manager to disable the block the minute it is dragged to a new region, and then enabled in the new region on the drop action. This in turn will (with the help of region manager) move the block visibility settings (as specified in the previous region) to the new region.
Moving blocks up and down in the same region will also improve the design experience with drupal blocks.

I have this module installed but your module is much better
Great work, you should start your own project

#10

Drag and drop would be a cool feature to easily manage the blocks instead of using the current admin block interface.

It is unfortunate that only a demonstration of drag and drop.

#11

Could you share your Module? looks great!

#12

It's here, but I haven't touched it in months so no idea how well it works anymore XD
http://foxis.intheclosets.com/user-block-move

#13

#12
Uploaded, in case when server goes down.

AttachmentSize
user_block_move.zip 8.33 KB
nobody click here