• Resolved codelad

    (@codecorun)


    Hi Support,

    I am very new to beaver addon development. I am just wondering why when I tried to build my own module I keep getting this error:

    Fatal error: Uncaught Error: Undefined constant “TEMPLATEPATH” in C:\xampp\htdocs\project\wp-includes\theme.php:158 Stack trace: #0 C:\xampp\htdocs\project\wp-content\plugins\beaver-builder-lite-version\classes\class-fl-builder-module.php(183): is_child_theme()

    I followed your documentation well and even I tried to copy one of your predefined modules in your plugin(of course I changed the module name) I still get the same error.

    Am I missing something?

    here’s my sample code:

    class BB_My_Module extends FLBuilderModule {
    
        public function __construct() {
    
          parent::__construct(array(
    
            'name'        => __('My Module', 'fl-builder'),
    
            'description' => __('Description of my module', 'fl-builder'),
    
            'category'    => __('Basic', 'fl-builder'),
    
          ));
    
        }
    
        public function render() {
    
          // Code for rendering the module's content
    
        }
    
        public function update($settings) {
    
          // Code for updating the module's settings
    
        }
    
    }
    
    FLBuilder::register_module('BB_My_Module', array(
    
      'general' => array(
    
        'title' => __('General', 'fl-builder'),
    
        'sections' => array(
    
          'section_1' => array(
    
            'fields' => array(
    
              'text_field' => array(
    
                'type' => 'text',
    
                'label' => __('Text Field', 'fl-builder'),
    
                'default' => 'Hello, world!',
    
              ),
    
              'image_field' => array(
    
                'type' => 'photo',
    
                'label' => __('Image Field', 'fl-builder'),
    
                'show_remove' => true,
    
                'connections' => array('photo'),
    
              ),
    
            ),
    
          ),
    
        ),
    
      ),
    
    ));

    UPDATE: I was able to build my own module but have to change a couple of lines in your classes.

    classes/class-fl-builder-module.php - line 183
    FROM: 
    
    if ( is_child_theme() && stristr( $dir_path, $stylesheet_directory ) ) {
    
    TO:
    
    if ( get_template_directory() && stristr( $dir_path, $stylesheet_directory ) ) {
    
    classes/class-fl-builder-model.php line 3075
    FROM: 
    
    self::$modules[ $instance->slug ]->form['advanced'] = self::$settings_forms['module_advanced'];
    
    TO: 
    
    self::$modules[ $instance->slug ]->form['advanced'] = isset(self::$settings_forms['module_advanced'])? self::$settings_forms['module_advanced'] : null;

    Making those changes in your core plugin is a VERY VERY bad idea that’s why I am asking for help. Please, I’m begging.

    • This topic was modified 1 year, 6 months ago by codelad.
    • This topic was modified 1 year, 6 months ago by codelad.
    • This topic was modified 1 year, 6 months ago by codelad.
Viewing 1 replies (of 1 total)
  • Plugin Contributor Jamie

    (@codente)

    Since this is marked as resolved, I hope that means you figured it out but let us know if you need more assistance!

Viewing 1 replies (of 1 total)
  • The topic ‘I can’t create custom module.’ is closed to new replies.