How can I add a custom module for Divi Wordpress theme? http://www.elegantthemes.com/gallery/divi/
Original modules are created in main-modules.php
Example:
class ET_Builder_Module_Gallery extends ET_Builder_Module { .... }
But the ET_Builder_Module
class is not accessible in my plugin, or in theme functions.php
I want to try settling the little debate here. class ET_Builder_Module_Custom_Module extends ET_Builder_Module {} actually works and main-modules.php can be modified freely IF a Child Theme is used. I recently ajaxified a Divi Theme and after update everything worked like a charm.
Note: It's always a good idea to check if there are updates on the files you use inside the child theme because sometimes you may need to update the child files also.
I hope this helped all future readers of this post.
HFGL with the new modules you are about to create ;)
The code above didn't work The function needs to be called as well.
Here's an example with working code from https://divi.space/blog/adding-custom-modules-to-divi/
Most other solutions here are way too complex. The simplest way is to load your custom module in the divi specific action hook
et_builder_ready
, like this:You can find the full demo-code on github. Along with some instructions how to get it work in the all new Divi 3 frontend builder:
https://github.com/stracker-phil/divi3-vb-custom-modules/
You can do it modifying the Divi theme files (which is bad)
For example, you can modify main-modules.php to add a new module:
After that you need to add the panel for the customizer in functions.php:
If you do a search in functions.php you'll find where to add it easily ;)
Place below in your functions.php file. The include file (I called it custom-modules.php) will be a class that extends ET_Builder_Module (which is very similar to WP_Widget). Just open the file from Divi>>includes>>builder>>main-modules.php. Use any of the preexisting modules as an example or basis for your new one. Copy and paste into your custom-modules.php. New class names, make edits as needed, etc.
For creating custom modules, I would use existing modules to create a design (layout), would save that design into Divi library and would use Text or Code modules and would write all HTML/jquery code there.
Like here, https://github.com/Skaidrius/Divi/tree/master/Layouts/Price-list