PHP code example of symbioticwp / acf-page-builder
1. Go to this page and download the library: Download symbioticwp/acf-page-builder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
symbioticwp / acf-page-builder example snippets
if (file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
namespace App\Blocks;
use Symbiotic\AcfPageBuilder\Blocks\AbstractBlock;
class TemplateBlock extends AbstractBlock {
protected function registerLayout() {
return [
'label' => 'Template Block',
'name' => 've-template-block',
'display' => 'block',
'sub_fields' => [
acf_tab(['label' => 'Details']),
acf_text( [ 'label' => 'Path to Template File', 'name' => 've-template-filename' ] ),
]
];
}
public function render() {
$this->
use App\Blocks\TemplateBlock;
add_action('symbiotic/acf_page_builder/register_page_blocks', function($pageBuilder) {
// Initialize Blocks with a class (for complex logic)
$pageBuilder->addLayout(new TemplateBlock());
});
/**
* Add a settings Tab to every Block
*/
add_action('symbiotic/acf_page_builder/add_layout_after', function($layoutConfig) {
if(!isset($layoutConfig['sub_fields'])) {
var_dump($layoutConfig);
}
$layoutConfig['sub_fields'] = array_merge(
$layoutConfig['sub_fields'],
addSettingsTab()
);
return $layoutConfig;
});
/**
*
* @return array
*/
function addSettingsTab() {
return [
acf_tab(['label' => 'Settings']),
acf_text([ 'label' => 'Container Class',
'name' => 've-settings-container',
'instructions' => 'You can define your own container classes which gets