Okay
  Public Ticket #2663923
wpbakery custom elements
Closed

Comments

  •  8
    byggis started the conversation

    Hi, we have used wpbakery in the previous and we have many custom made elements we want to move over to salient now as we want to use Salient as "back-office" as the functions and customizations is so much better then the normal wpbakery. Is it any way to to this easy? and still keep them when we upgrade. We do understand we need to use the child theme, but cant get it to work.

    I cant find anything in the support files.

  •  8,849


    ThemeNectar Support Team 

  •  8
    byggis replied

    Hi Tahir, 

    I found that before, it is how to replace your templates, not how to add a new one. I want to keep your templates, as they are great and thats why we are switching to salient, but we need to have the custom made templates we have from before in wpbakery and move them to salient. 

  •  8,849
    Tahir replied

    Escalating to the Developer so he may add in a further response. 

    Thanks 


    ThemeNectar Support Team 

  •  8
    byggis replied

    Thank you, much appricated!

  •  1,075
    ThemeNectar replied

    Hey byggis!

    Adding a custom element via a child theme can be handled by following the steps below.

    Create directories in the child theme to hold the element maps (where you register the element and settings for it) and template files (where the element markup exists). For example, 

    • salient-child/custom-elements/maps
    • salient-child/custom-elements/templates

    For this example, we'll create a new element called "a_new_el".

    In your child functions.php, add the following:

    add_action('vc_before_init', 'nectar_wpbakery_blocks');
    function nectar_wpbakery_blocks() {
        vc_lean_map('a_new_el', null, get_stylesheet_directory() . '/custom-elements/maps/a_new_el.php');
       // more maps can go here.
    }

    Inside the salient-child/custom-elements/maps/a_new_el.php file, you can use the  WPBakery map parameters as you're used to: https://kb.wpbakery.com/docs/inner-api/vc_map/

    Now to connect the custom element to the template file, you can use the parameter "html_template" into your map file (custom-elements/maps/a_new_el.php) which will specify where to load the template file from for rendering on the frontend. An example of that would look like:

    return array(
        "name" => esc_html__("A New El", "js_composer"),
        "base" => "a_new_el",
        "html_template" => get_stylesheet_directory() . '/custom-elements/templates/a_new_el.php',
        "icon" => "icon-wpb-milestone",
        "category" => esc_html__('Super Elements', 'js_composer'),
        "description" => '',
        "params" => array(...etc
    

    After doing that, simple edit the custom-elements/templates/a_new_el.php file to control the output of the elementsmile.png

  •  8
    byggis replied

    Hi ThemeNectar,

    I been trying but I dont seem to get it to work, is it sure its the correct way? I am not a professional on this, but I would think I could follow the instructions. Thank you :)

  •  1,075
    ThemeNectar replied

    Hey byggis,

    Yes, the method has been tested. If you'd like to provide a temporary admin account, I'd be glad to take a look at your child theme to see if I can spot any issues.

    Cheers