StaticPageBundle
Installation
Install bundle through composer:, (*1)
composer.phar require sokil/static-page-bundle
Add bundle to AppKernel:, (*2)
<?php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
new Sokil\StaticPageBundle\StaticPageBundle(),
);
}
}
Configuration
Page view
Place file to app/Resources/StaticPageBundle/views/Page/index.html.twig with your own markup of static page.
Page instance Sokil\StaticPageBundle\Entity\Page accessable as page variable, also locale must be passed to template. To get localized data, call page.getLocalizations()[locale] which gives you instance of Sokil\StaticPageBundle\Entity\PageLocalization., (*3)
Routing
To enable default routing configuration just add routing.yml to you routes config app/config/routing.yml:, (*4)
static_page:
resource: "@StaticPageBundle/Resources/config/routing.yml"
prefix: /
Or add your own routes for required actions., (*5)
To route any unexisted url to static page handler, you need to add some configuration to app/config/config.yml:, (*6)
cmf_routing:
chain:
routers_by_id:
router.default: 200
static_page.page_router: 100
dynamic:
persistence:
orm:
enabled: true
Roles
Register role at app/config/security.yml:, (*7)
# http://symfony.com/doc/current/book/security.html
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
# http://symfony.com/doc/current/book/security.html#hierarchical-roles
role_hierarchy:
ROLE_PAGE_MANAGER: [ROLE_USER]
SPA view
Bundle has some SPA routes and dependencie for managing static pages, so you can configure them,
for example with sokil/frontend-bundle:, (*8)
{% import "@FrontendBundle/Resources/views/macro.html.twig" as frontend %}
{% import "@StaticPageBundle/Resources/views/macro.html.twig" as staticPageSpa %}
{{ staticPageSpa.jsResources() }}
Deploy
If you want to use embedded editor, you need to setup SPA., (*9)
You need to execute grunt tasks to build SPA:, (*10)
npm install
bower install
grunt
Bundle uses assetic bundle, so you need to register it in assetic config:, (*11)
assetic:
bundles:
- StaticPageBundle