12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Dec 31, 2019

How to Quickly Disable any Element in Oxygen

David Browne

If you find yourself building lots of versions of sections/elements and need to prevent some of them from being output on the frontend, here’s a quick way to do it.

All we really need to hide an element is to set a condition that we know will be false. This can take too much time clicking to set up the condition, choosing the operator and typing the value each time.

I’ve been using this code snippet to make the process a little bit quicker. (I’m still hoping something will get built into the UI to make this a one-click process, but this saves a few clicks).

This is the code we add to our code snippets;

if( function_exists('oxygen_vsb_register_condition') ) {
	oxygen_vsb_register_condition('Disable Element', array('custom' => false), array(''), 'false', '');

This will register a new ‘fake condition’. It has no parameters, it’s always going to be false no matter what.

The ‘disable element’ will appear at the very top of the conditions list for easy access. No conditions to set, just select ‘Disable Element’ then close the conditions modal.

All done

You can still use the condition settings of ‘Always Show’ and ‘Always Hide’ to toggle visibility inside the builder, knowing the element won’t be output on the front.

Simply remove the condition to allow the element to reappear on the site.