0

I want draggable and sortable contents by admin. So, installed jQuery UI and put this code in my main.js:

$(function() {
    $( ".panels-flexible-region" ).sortable({
      revert: true
    });
    $( "#makyaj .views-row" ).draggable({
      connectToSortable: ".panels-flexible-region",
      helper: "clone",
      revert: "invalid"
    });
    $( "ul, li" ).disableSelection();
  });

Yes, it works. But i want use this option only admin user. Whether View Sort Type: Jquery Draggable and qhat sets the admin users so they can see it.

Is it possible? Can i integration Views and jQuery UI Draggable?

1

You can do something along these lines in a custom module...

function mymodule_init() {
  global $user;

  if ($user->uid==1) { // super/admin user, add role based logic if needed or desired
    drupal_add_js('path/to/admin-only.js');
  }
}

...where 'path/to/admin-only.js' is a file containing JS you want added only for your admin/super user. Look into drupal_add_js() for more information.

| improve this answer | |
1

I know this isn't exactly what you asked for, but have you considered using the draggable views module? It does what you aim to do without you having to code anything.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.