PHP code example of bozboz / jam
1. Go to this page and download the library: Download bozboz/jam 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/ */
bozboz / jam example snippets
// todo: specify convention
[
'default_everything_entities' => // key used where?
new Type([
'menu_title' => 'Default Everything Entities',
'name' => 'Default Everything Entities', // used where?
]),
'custom_everything_entities' =>
new CustomType([
'menu_title' => 'Custom Everything Entities',
'name' => 'Custom Entities',
'report' => MyReport::class,
'link_builder' => MyLinkBuilder::class,
'menu_builder' => MyMenuBuilder::class,
'entity' => MyEntity::class,
'search_handler' => MySearchHandler::class,
'decorator' => MyDecorator::class
'can_restrict_access' => true, // used where?
'gated' => true, // used where?
'custom_attribute' => ''
])
];
$mapper = $this->app['EntityMapper'];
$mapper->register([
'callout-boxes' => new \Bozboz\Jam\Types\EntityList('Callout Boxes'),
]);
/**
* Jam Catch All
*/
Route::get('{entityId}{slug?}', [
'as' => 'entity-by-id',
'uses' => '\Bozboz\Jam\Http\Controllers\EntityController@forId'
])->where('entityId', '(\d+)')->where('slug', '(/.+)?');
Route::get('{entityPath}', [
'as' => 'entity',
'uses' => '\Bozboz\Jam\Http\Controllers\EntityController@forPath',
])->where('entityPath', '(.+)?');
$pages = $entityRepository->forType('page')->get()->loadFields('content', 'image');
$entities->loadRelationFields('categories', ['description', 'image']);
protected function getPreviewData($page)
{
return [
'preview' => str_limit(strip_tags(
$page->intro_text ?: $page->content
), 200),
'image' => Media::getFilenameOrFallback($page->image, null, 'search-result'),
];
}
protected function getSearchableData($page)
{
return strip_tags(implode(' ', [
$page->intro_text,
$page->content,
]));
}