This bundle provides an easy way to set meta tag directly from the front. The principe is very simple. Just click on the "Meta" tab which appears on your front and set meta data for the page.
To install MetaBundle with Composer just type in your terminal:
php composer.phar require mdespeuilles/metabundle
Now update your AppKernel.php
file, and
register the new bundle:
<?php
// in AppKernel::registerBundles()
$bundles = array(
// ...
new Mdespeuilles\MetaBundle\MdespeuillesMetaBundle(),
// ...
);
Execute the following command to make css and js assets available in your Symfony application:
php bin/console assets:install --symlink
Load the routes of the bundle by adding this configuration at the very top
of the app/config/routing.yml
file:
# app/config/routing.yml
mdespeuilles_meta:
resource: "@MdespeuillesMetaBundle/Resources/config/routing.yml"
# ...
Update your shema with this command :
php bin/console doctrine:schema:update --force
Edit the layout call the meta form.
{{ render(controller('MdespeuillesMetaBundle:Meta:meta', {request: app.request})) }}
<script src="{{ asset('bundles/mdespeuillesmeta/js/meta.js') }}"></script>
<link rel="stylesheet" href="{{ asset('bundles/mdespeuillesmeta/css/meta.css') }}">
You should display this form only to granted roles you can simply add a condition to display it. For exemple :
{% if is_granted('ROLE_SUPER_ADMIN') %}
{{ render(controller('MdespeuillesMetaBundle:Meta:meta', {request: app.request})) }}
<script src="{{ asset('bundles/mdespeuillesmeta/js/meta.js') }}"></script>
<link rel="stylesheet" href="{{ asset('bundles/mdespeuillesmeta/css/meta.css') }}">
{% endif %}
Just click on the "Meta" tab which appears on your front and set meta data for the page.