Update composer.json
by adding this to the repositories
array:
{
"type": "vcs",
"url": "https://github.com/ohmediaorg/backend-bundle"
}
Then run composer require ohmediaorg/backend-bundle:dev-main
.
Import the routes in config/routes.yaml
:
oh_media_backend:
resource: '@OHMediaBackendBundle/config/routes.yaml'
Run php bin/console make:migration
then run the subsequent migration.
Also run npm install bootstrap bootstrap-icons sortablejs tinymce nice-select2
Create config/packages/oh_media_backend.yaml
with the minimum config:
oh_media_backend:
tinymce:
Add the following to your backend JS entry point:
import '../../vendor/ohmediaorg/backend-bundle/assets/js/index.js';
Add the following to your backend Sass file:
@import '../../../vendor/ohmediaorg/backend-bundle/assets/scss/style';
This should typically be all that is needed for backend styles.
Make sure webpack encore is setup to copy TinyMCE files:
.copyFiles({
from: './node_modules/tinymce',
to: 'js/tinymce/[path][name].[ext]',
pattern: /\.(js|min\.css)$/,
})
Such that <script src="/backend/js/tinymce/tinymce.min.js"></script>
is valid.
There is a function to initialize a TinyMCE instance:
OH_MEDIA_TINYMCE(container, selector);
All of your backend templates should ultimately extend @OHMediaBackend/base.html.twig
.
The bundle also provides a simple form template @OHMediaBackend/form.html.twig
.
Any styles/javascripts that need to be on every backend template can be set up by overriding:
@OHMediaBackend/include/stylesheets_global.html.twig
@OHMediaBackend/include/javascripts_global.html.twig
The logo can be similarly overridden via @OHMediaBackend/include/logo.html.twig
in combination with a Sass variable $oh-logo
used for the mobile menu icon.
Create entity classes using the boilerplate command:
php bin/console ohmedia:backend:boilerplate
Class name of the entity:
> Post
then add your custom fields using the maker command:
$ php bin/console make:entity
Class name of the entity to create or update (e.g. TinyGnome):
> Post
You may want to represent some of these custom fields in the
App\Form\PostType
class that was auto-generated.