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].
Hi there,
First of all – great plugin – good work to all developers involved.
Second, is there a way to programmatically define Page Layouts? Reading your (somewhat limited) documentation on it just shows to create a new “Page” with the desired layout, and then you can clone it on other Posts/Pages etc.
But if I don’t want a “page” existing just for this template, is there a way I can create a Prebuilt Layout in the Functions.php or elsewhere?
Thanks,
Jamie.
Hi Jamie
Glad to hear you’re liking our little plugin :)
OK, so let me take a quick stab at explaining how to create a prebuilt layout. Vantage is one theme that’s adding it’s own prebuilt layouts. This is the code it’s using.
So basically it’s filtering the layouts var passed through the siteorigin_panels_prebuilt_layouts filter.
You’ll need to activate development mode in Page Builder to get the array you need to pass to the layouts array. In your WordPress config file (wp-config.php) add the following.
In your development environment, create a page using Page Builder. Save that page, then inspect the HTML source code of the page and search for the string “// Page Builder Data dump”. You should see a full PHP array that fully defines the layout. This is what you pass to the $layouts array.
Just be sure to add a key called ‘name’ with the name of the prebuilt layout.
To get a better idea, download our Vantage theme and check out the file inc/panels.php
Hope that helps :)
Hello Jamie,
I can’t see the Data Dump in source code.
I added define(‘SITEORIGIN_PANELS_DEV’, true); in wp-config.php but I can’t find any dump in source, not in backend or in frontend of the page.
I tryed using the serialized data as described here: https://wordpress.org/support/topic/how-to-add-prebuilt-layouts-to-a-custom-theme
but I have a lot of HTML in that database field, so including it in a php function as a variable it’s quite a job.
If I wont be able to see the dump, maybe I can process that panels_data postmeta with a custom script so I can transform that into an array to use in vantage_prebuilt_page_layouts function?
SOLVED
I’ve searched in plugin script for “// Page Builder Data dump” and I found it in inc/debug.php
don’t know why it’s not working, anyway I put this piece of code from debug.php
<?php
echo "ID, ‘panels_data’, true));
echo “\n\n–>”;
?>
in my page template, and now I can see the array well formatted. Cool :)
ops, I didn’t include the code in the code tag, sorry it got deleted. here it is:
sorry if I keep posting, but I’m not done yet :(
I used that array and the prebuilt layout is present, but if I load it it’s just empty.
this is the code I’ve used:
1) I’ve included the unserialized array in a variable, like this.
2) then I’ve copied the method used in siteorigin-panels.php line 979
Any idea why?
sorry I made an error in editing the pasted code above
is actually