PHP code example of amphibee / acf-blocks
1. Go to this page and download the library: Download amphibee/acf-blocks 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/ */
amphibee / acf-blocks example snippets
use \AmphiBee\AcfBlocks\Block;
use \Extended\ACF\Fields\Text;
use \Extended\ACF\Fields\Textarea;
Block::make('My beautiful block', 'my_beautiful_block')
->setFields([
Text::make('Title', 'title'),
Textarea::make('Content', 'content'),
])
->disableCustomClasseName()
->setAllowedBlocks([
'core/paragraph',
'core/heading',
])
->setJsxTemplate([
['core/heading', [
'level' => 2,
'placeholder' => 'Title Goes Here',
]],
['core/paragraph', [
'placeholder' => 'Content goes here',
]]
])
->loadAllFields()
->setMode('edit')
->setIcon('format-aside')
->setAlign('full')
->enableJsx()
->setRenderTemplate('partials/my-beautiful-block.php');
use \AmphiBee\AcfBlocks\Block;
use \Extended\ACF\Fields\Text;
use \Extended\ACF\Fields\Textarea;
Block::make('My beautiful block', 'my_beautiful_block')
->setFields([
\Extended\ACF\Fields\Text::make('Title', 'title'),
\Extended\ACF\Fields\Textarea::make('Content', 'content'),
])
->setMode('preview')
->setIcon('editor-code')
->setAlign('wide')
->enableJsx()
->setView('partials.my-beautiful-block', [
'key' => 'value',
]);
<div class="p-4">
var_dump($viewData);
<div class="p-4">
<h1>{{$field->title}}</h1>
<p>{{$field->content}}</p>
<p>{{$viewData['key']}}</p>
{!! $innerBlocks !!}
</div>
use \AmphiBee\AcfBlocks\BlockCategory;
BlockCategory::make('My beautiful category', 'my_beautiful_category')
->setIcon('wordpress')