Skip to content

Olaw2jr/modular-page-builder

 
 

Repository files navigation

Modular Page Builder

Modular page builder for WordPress

image

Basic usage

Out of the box, modules are available for header, text and image only.

You must add post type support for the builder add_post_type_support( 'page', 'modular-page-builder' );

You must handle the output of the page builder data manually. Here is an example of simply replacing the post content.

add_filter( 'the_content', function( $content, $id = null ) {

	$id = $id ?: get_the_ID();

	if ( post_type_supports( get_post_type( $id ), 'modular-page-builder' ) ) {
		$plugin  = MPB_Plugin::get_instance()->get_builder( 'modular-page-builder' );
		$content = $builder->get_rendered_data( $id );
	}

	return $content;

}

Custom Modules

  • Register module using `$plugin->register_module( 'module-name', 'ModuleClass' );
    • Module Class should extend ModularPageBuilder\Modules\Module.
    • It should provide a render method.
    • Set $name property the same as module-name
    • Define all available attribuites in $attr array.
    • Each attribute should have name, label and type where type is an available field type.

Extra Customization

  • By default, your module will use the edit-form-default.js view.
  • You can provide your own view by adding it to the edit view map: window.modularPageBuilder.editViewMap. Where the property is your module name and the view is your view object.
  • You should probably extend window.modularPageBuilder.views.ModuleEdit.
  • You can still make use of the built in field view objects if you want.

Available Field Types

  • text
  • textarea
  • html
  • attachment
  • link

About

Modular page builder for WordPress

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 78.5%
  • PHP 12.0%
  • CSS 7.1%
  • HTML 2.4%