I would like to display a view page with a draggable table if the user has permissions to edit the view, otherwise display it with a custom theme template.

How would I do that?

Comments

ygerasimov’s picture

Status: Active » Postponed (maintainer needs more info)

There is permission 'Allow Reordering' that allows user to use draggable views. If this is not enough please describe the permissions model you would like to implement so we will think about how to reach it.

damd’s picture

Yes, I can use that permission to only allow reordering for e.g. administrators. However, I would like to be able to use a custom template if the user does not have the permission to reorder the nodes in the view.

E.g., if I am the administrator I see the draggable interface as normal. But if I'm anonymous, I will not see the draggable table - instead I will see another UI which is rendered using e.g. views-view-fields--my-view-name.tpl.php.

Is this possible with DraggableViews today?

ygerasimov’s picture

Yes you can do that. It is not functionality of draggableviews but more for theming. You can create function in your theme MYTHEME_preprocess_views_view_fields(&$vars). There you can check whether user doesn't have permission to use drag functionality add your custom template suggestion using $vars['template_files'][] = 'CUSTOM_TEMPLATE';

I you need to change any other template you can look at file theme/theme.inc of views module for names of preprocess functions.

Please advise whether it is what you need so I can close this issue.

damd’s picture

Thank you, that will do!

Note however that my function needed to be declared as:
MYTHEME_preprocess_draggableviews_view_draggabletable(&$vars)

ygerasimov’s picture

Status: Postponed (maintainer needs more info) » Fixed

Great. Marking this issue as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.