Is there any way to hide the Contextual View Modes Settings box that's attached to a content type from logged in users other than the admin? I have tried hiding it using field permissions but can only stop the editing or creating of new CVMs and the box still appears showing the Enabled Global Contextual View Modes.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rickdrup’s picture

For anyone else that may want to do this, I'm not sure what the "correct" approach is but as I can't seem to hide the vertical tab for CVMs using permissions, I have just used a simple CSS rule to hide the field.

rickdrup’s picture

After having tried a few modules and various other CSS rules to stop the CVM vertical tab from being visible by logged in users but still visible and editable by the admin I had to resort to placing the following in template.php:

function THEME_NAME_form_alter(&$form, $form_state, $form_id) {

  switch ($form_id) {
    case 'CONTENT_TYPE_node_form': // just for 'node_type', remove if you want broader
	global $user;
	if(isset($user)) {
  	  if($user->uid!=1){
     	 $form['additional_settings']['#access'] = FALSE;
   		break; 
	  }
	}
  }
}

The issue seems to be that the permissions for this field do not work properly and all users can view the field despite the permissions not allowing them.

davidneedham’s picture

Thanks @rickdrup. This solution works for me too.

To fix for realz, we'll need to patch into the module's code rather than the theme, but this is a quick fix.

Helrunar’s picture

Status: Active » Needs review
FileSize
511 bytes

Here is a small patch, that will fix the problem and will make the permissions get work correctly

rrrob’s picture

Status: Needs review » Reviewed & tested by the community

#4 Works perfect.

Alauddin’s picture

Issue summary: View changes

#4 works - tested with 7.x-1.2-alpha1+9-dev

sherakama’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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