Skip to content

Instantly share code, notes, and snippets.

@Dmi3yy
Created November 20, 2019 13:11
Show Gist options
  • Save Dmi3yy/fe9581610c53de7a26935d6a7d783c2b to your computer and use it in GitHub Desktop.
Save Dmi3yy/fe9581610c53de7a26935d6a7d783c2b to your computer and use it in GitHub Desktop.
PageBuilder Evo2.0
PageBilder
container.pbcontent.php
<?php
return [
'title' => 'Контент',
// 'show_in_templates' => [ 3 ],
// 'show_in_docs' => [ 2 ],
// 'hide_in_docs' => [ 10, 63 ],
// 'addType' => 'images',
'placement' => 'tv',
];
files.php
<?php
return [
'title' => 'Файлы',
'container' => [
'pbcontent'
],
'fields' => [
'files' => [
'caption' => 'Files',
'type' => 'group',
'fields' => [
'text' => [
'caption' => 'Название файла',
'type' => 'text',
],
'file' => [
'caption' => 'Файл',
'type' => 'file',
],
],
],
],
'prepare' => function($options, &$values) {
$values['block_id'] = 'files';
}
];
text.php
<?php
return [
'title' => 'Контент',
// 'show_in_templates' => [ 4 ],
// 'show_in_docs' => [ 2 ],
// 'hide_in_docs' => [ 5 ],
// 'order' => 1,
'container' => [
'pbcontent'
],
'fields' => [
'title' => [
'caption' => 'Заголовок',
'type' => 'text',
'default' => '',
],
'subtitle' => [
'caption' => 'Подзаголовок',
'type' => 'text',
'default' => '',
],
'richtext' => [
'caption' => 'Text',
'type' => 'richtext',
'default' => '',
'theme' => 'custom',
'options' => [
'height' => '300px',
],
],
],
'prepare' => function($options, &$values) {
$values['block_id'] = 'text';
}
];
slider.php
<?php
return [
'title' => 'Слайдер',
// 'show_in_templates' => [ 4 ],
// 'show_in_docs' => [ 2 ],
// 'hide_in_docs' => [ 5 ],
// 'order' => 1,
'container' => [
'pbcontent'
],
'fields' => [
'images' => [
'caption' => 'Изображения',
'type' => 'group',
'fields' => [
'image' => [
'caption' => 'Изображение',
'type' => 'image',
],
],
],
'richtext' => [
'caption' => 'Текст слева если нужно',
'type' => 'richtext',
'default' => '',
'theme' => 'custom',
'options' => [
'height' => '200px',
],
],
],
'prepare' => function($options, &$values) {
$values['block_id'] = 'slider';
}
];
$this->data['pagebuilder'] = $this->evo->runSnippet('PageBuilder', ['container' => 'pbcontent','renderTo' => 'array'])[0];
@include('partials.pagebuilder.pbcontent', ['data'=>$pagebuilder])
partials/pagebuilder/pbcontent.blade.php
@foreach($data as $block)
@include('partials.pagebuilder.parts.'.$block['block_id'], ['data'=> $block])
@endforeach
partials/pagebuilder/parts/files.blade.php
<div>
<div class="container">
<div class="row files">
@foreach($data['files'] as $file)
<div>
<a href="/{{ $file['file'] }} " target="_blank">{{ $file['text'] }}</a>
</div>
@endforeach
</div>
</div>
</div>
partials/pagebuilder/parts/text.blade.php
<div>
<div class="container">
@if( $block['title'] != '' || $block['subtitle'] != '')
<div class="row">
<div class="col-lg-7">
@if( $block['title'] != '')
<h2>{!! $block['title'] !!}</h2>
@endif
@if( $block['subtitle'] != '')
<h4>{!! $block['subtitle'] !!}</h4>
@endif
</div>
</div>
@endif
<div class="text h6">
{!! $block['richtext'] !!}
</div>
</div>
</div>
partials/pagebuilder/parts/slider.blade.php
<div class="content">
{!! $data['richtext'] !!}
</div>
<div class="swiper-wrapper">
@foreach($data['images'] as $image)
<div class="swiper-slide">
<img src="/{{ $image['image'] }}" alt="">
</div>
@endforeach
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment