Home>Support>How to Bundle Prebuilt Layouts in Page Builder 2.5+?

How to Bundle Prebuilt Layouts in Page Builder 2.5+?

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

The documentation for bundling prebuilt layouts (https://siteorigin.com/docs/page-builder/bundling-prebuilt/) refers to v2.4.x.

Version 2.5 has import / export functionality for layouts but it is unclear how to bundle these with a theme.
I’ve tried out the new Layout Viewer theme on Github but this is overkill for what I want to do.

How do I set up bundled layouts so my users can use them without needing to import each time?

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 7 years, 11 months ago Andrew Misplon
    Hi, I Work Here

    Hi Julian

    Thanks for the bump. Will get those docs updated ASAP. The new method will look something like this:

    https://github.com/robhope/fullsingle/blob/master/functions/function-layouts.php
    https://github.com/robhope/fullsingle/blob/master/layouts/flyleaf/flyleaf.php

    Let me know if that helps.

  2. 7 years, 11 months ago Julian Weaver

    The old documentation for functions.php still works:

    function mytheme_prebuilt_layouts($layouts){ 
        ...[see code below]
        return $layouts;
        }
    
    add_filter('siteorigin_panels_prebuilt_layouts','mytheme_prebuilt_layouts');

    Unfortunately you need to decode the json and extract the array from the resulting object:

    function mytheme_prebuilt_layouts($layouts){
    
        $layouts['<name>'] = array(
            'name' => __('Two Column', 'theme'),    // Required
            'description' => __('Two Column Template', 'theme')    // Optional
        );
        $arr = json_decode('<exported json here>');
        $layouts['<nane>']['widgets'] = $arr->widgets;
        
     return $layouts;
    }
    add_filter('siteorigin_panels_prebuilt_layouts','mytheme_prebuilt_layouts');

    NB: this is just an example, you’d probably want to decode the json once offline and insert the array instead.

  3. 7 years, 11 months ago Julian Weaver

    @andrew, thanks for the code. I posted before seeing your reply. I’ll try that now.

  4. 7 years, 11 months ago Julian Weaver

    @Andrew Thanks, that works.

    For anyone copy/pasting @andrew’s code:

    the layouts directory should go at the top level of your themes directory, not in your theme
    Change the path set in $layout_dir in function_layouts.php to move it into your theme dir.

  5. 7 years, 11 months ago Andrew Misplon
    Hi, I Work Here

    Thanks for adding the notes. Glad to hear you’ve made progress. Sorry for the hassle.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More