Forums/Tips & Tricks

Working around Control Panel customization limitations

Christopher Haupt
posted this on July 18, 2011, 19:38

Suppose you want to make certain fields in a Custom Item Type editing form invisible to content editors.

The current JSON configuration for customizing some of the control panel experience doesn't yet reach down to the field level of particular forms. That said, there is a way you could accomplish what you want to do. We provide a config called admin.custom.control_panel.head_markup that can be used to inject a string of markup into the <head> section of each and every control panel page.

This has been used to create a JavaScript script that detects the current role of the logged in user, sniffs the current page to see if it is the form/markup that you want to change, and if so, hides/moves/transforms the elements on the page.

So, you could put something like this in a .js file on your site (note jQuery and the WebvantaAdmin tools are available to you):

$(document).ready(function() { 
if(WebvantaAdmin.getUIRValue("r").search("content") >= 0 && $('form.formclass').length > 0) { 
$("#myfieldid").hide(); 

});

where formclass = the unique class generated by the system of the form for that CIT (use Inspect Element in your browser to get this). myfieldid would be the desired name of the field to hide. Since our standard CIT forms are wrapped in some divs and list elements, that expression would probably be a little more complicated and use the jQuery ancestor DOM traversal support.

If you need help with jQuery expressions, feel free to post a question in our forums.

Once you save this JS file someplace in your account, you should set the config setting up with something like

<script type="text/javascript" src="/mycustomizer.js"></script>

And you should be all set.