Extend Background Control Group, Problem Hooking into Color Control #24731
Replies: 1 comment 1 reply
-
To add functionality to a control or group you can do something like this:
In this example I'm replacing the normal background controls with my own class 'Responsive_Group_Background' that extends their regular background controls class and adds in an extra image field. Inside Responsive_Group_Background we do that by overloading the init_fields method:
In this case I'm adding a second background image for super large screens, but its the same idea where you would need to use whatever element type you wanted. You can look in the parent elementor class and copy whatever item type you want to get the format and modify it to what you need. If you want to do much more than that though you're going to have to extend and overload some of the core elementor classes to get access to the rendering functions which is significantly more complicated. I opened up this ticket (#11564) because the only way to do anything with section/column stuff requires some changes to do cleanly. |
Beta Was this translation helpful? Give feedback.
-
Description
I'm trying to add responsive controls to the color control of the background control group. I want to be able to set different background colors by device for columns and sections in the style tab of the editor.
I thought I could use a hook to add the
'responsive' => true
parameter to thecolor
control settings array inGroup_Control_Background
, but my code isn't working. I was trying to hook in and update the control for$fields['color']
in elementor/includes/controls/groups/background.php.How do I add a control parameter when updating an existing control like this? Am I missing something to access the inner control of a group, or is there another way to go about this? Thanks for any suggestions.
(I'm aware of PAFE/piotnet plugin for responsive background, but that adds a second background styles tab and is confusing for clients. I'd much rather hook into the existing background control if I can!)
Prerequisites
Beta Was this translation helpful? Give feedback.
All reactions