laradium / laradium-content
- dev-master
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.1
- v1.0.0
- dev-l5.8
- dev-interface-builder
- dev-temp-master
- dev-l5.7
- dev-fix/sidebar-gap
- dev-feature/page-api
- dev-feature/previewable_pages
- dev-feature/sitemap-middleware
- dev-feature/custom_sitemap_url
- dev-LAR-10
- dev-LAR-7
- dev-LAR-16
- dev-LAR-3
- dev-LAR-4
This package is not auto-updated.
Last update: 2024-12-20 12:47:18 UTC
README
Installation
For local use
- Add this to your project repositories list in
composer.json
file
"repositories": [
{
"type": "path",
"url": "../packages/laradium"
},
{
"type": "path",
"url": "../packages/laradium-content"
}
]
Directory structure should look like this
-Project
-packages
--laradium
--laradium-content
For global use
"repositories": [
{
"type": "git",
"url": "https://github.com/laradium/laradium.git"
},
{
"type": "git",
"url": "https://github.com/laradium/laradium-content.git"
}
]
composer require laradium/laradium-content dev-master
php artisan vendor:publish --tag=laradium-content
- Configure
config/laradium.php
file with your preferences - Add widgetConstructor field to you
laradium.php
field list
'widgetConstructor' => \Laradium\Laradium\Content\Base\Fields\WidgetConstructor::class,
Usage
By default there comes Main channel with widget constructor, which allows you to create sortable widget blocks for your needs.
Creating new channels
- Run this command (It automatically creates model for you You can pass
--t
argument to also create translations model)
php artisan laradium:channel Blog
It will create new Channel under App\Laradium\Channels
It should look like this
<?php
namespace App\Laradium\Channels;
use App\Models\Channels\Blog;
use Laradium\Laradium\Base\FieldSet;
use Laradium\Laradium\Content\Models\Page;
Class BlogChannel
{
/**
* @param FieldSet $set
*/
public function fields(FieldSet $set)
{
$set->morphsTo(Blog::class, Page::class)->fields(function (FieldSet $set) {
$set->text('author');
$set->wysiwyg('content');
})->morphName('content');
$set->widgetConstructor();
}
}
You need to create model for Blog channel where you can specify all your needed columns and using morphsTo
field type you can add them to you channel
Creating widgets
- Run this command
php artisan laradium:widget
(It automatically creates model for you You can pass--t
argument to also create translations model)
It creates a widget under App\Laradium\Widgets
<?php
namespace App\Laradium\Widgets;
use App\Models\Widgets\Hiw;
use Laradium\Laradium\Base\FieldSet;
use Laradium\Laradium\Content\Base\AbstractWidget;
class HiwWidget extends AbstractWidget
{
/**
* @var string
*/
protected $model = Hiw::class;
/**
* @var string
*/
protected $view = 'widgets.HiwWidget';
/**
* @param FieldSet $set
* @return mixed|void
*/
public function fields(FieldSet $set)
{
$set->text('title')->translatable();
$set->text('description')->translatable();
$set->hasMany('items')->fields(function (FieldSet $set) {
$set->text('title')->translatable();
$set->text('description')->translatable();
})->sortable('sequence_no');
}
}
You can specify your fields under fields
method.
Page resolver
To actually return created pages, you need to add the page resolver route at the end of your routes file, or to your RouteServiceProvider.php
file.
To do this, you can simply use the helper method content()->pageRoute()
, or you can create your own route, but as the resolver route is configurable, there shouldn't be a need for that.
The config file, provides you with some options, to change the behaviour of the page resolver, in case you need some customization.
middlewares
- Change what middlewares the resolver route will usecustom_uri
- Provides you with an option, to define a function name, that will return a custom uriprepend_locale
- Adds an iso code to the uri. So the urlhttps://example.com/my-cool-page
will becomehttps://example.com/en/my-cool-page
uses
- Defines, what controller and method will be used to actually resolve the route.