PHP code example of fitzage / optimus-bard
1. Go to this page and download the library: Download fitzage/optimus-bard 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/ */
fitzage / optimus-bard example snippets
use Fitzage\OptimusBard\TransformBard;
'transformers' => [
'content' => function ($content) {
return TransformBard::transform($content, 'collections/pages/page', 'content');
},
]
'transformers' => [
'blocks' => function ($blocks) {
return TransformBard::transform(
$blocks,
'collections/pages/pages',
'blocks',
['hero', 'features', 'testimonials'], // Additional set types to
use Fitzage\OptimusBard\TransformBard;
return [
'default' => env('STATAMIC_DEFAULT_SEARCH_INDEX', 'default'),
'indexes' => [
'pages' => [
'driver' => 'algolia',
'searchables' => 'collection:pages',
'fields' => ['title', 'blocks', 'url'],
'transformers' => [
'blocks' => function ($blocks) {
return TransformBard::transform(
$blocks,
'collections/pages/pages',
'blocks',
['hero', 'cta', 'features', 'testimonials', 'pricing'],
['max_depth' => 4]
);
},
'url' => function ($url) {
return url($url);
},
]
],
'blog' => [
'driver' => 'algolia',
'searchables' => 'collection:blog',
'fields' => ['title', 'content', 'excerpt', 'url'],
'transformers' => [
'content' => function ($content) {
return TransformBard::transform($content, 'collections/blog/blog', 'content');
},
'url' => function ($url) {
return url($url);
},
]
],
],
'drivers' => [
'algolia' => [
'credentials' => [
'id' => env('ALGOLIA_APP_ID', ''),
'secret' => env('ALGOLIA_SECRET', ''),
],
],
],
];
// v1.x syntax (still supported)
'body' => function ($body) {
return TransformBard::transform($body, 'collections/blog/article', 'body', ['columns', 'info_block']);
},
// v2.x syntax (recommended)
'body' => function ($body) {
return TransformBard::transform(
$body,
'collections/blog/article',
'body',
['columns', 'info_block'],
['max_depth' => 3]
);
},