it-blaster/content-bundle

Symfony2 bundle for site content management, require Propel, Sonata and jstree

v1.0.3 2015-06-30 13:17 UTC

This package is not auto-updated.

Last update: 2024-10-26 17:29:39 UTC


README

Build Status Scrutinizer Code Quality

Installation

Add to composer.json and install

{
    "require": {
        "it-blaster/content-bundle": "dev-master"
	},
}

Add bundle to AppKernel.php

<?php
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Etfostra\ContentBundle\EtfostraContentBundle(),
    );
}

Add to routing.yml

EtfostraContentBundle:
    resource: .
    type: extra

Build models, run SQL and install assets

$ php app/console propel:model:build
$ php app/console propel:migration:generate-diff
$ php app/console propel:migration:migrate
$ php app/console assets:install

To enable labels translation in SonataAdmin

framework:
    translator:      { fallbacks: ["%locale%"] }

Cofigure

Edit your config.yml, add etfostra_content:

etfostra_content:
    page_controller_name: EtfostraContentBundle:PageFront:page
    page_template_name: EtfostraContentBundle:Front:default.html.twig
    module_route_groups: # optional, modules (routes groups)
        - { name: News, routes: @AcmeAppBundle/Resources/config/routing_news.yml }
        - { name: Catalog, routes: @AcmeAppBundle/Resources/config/routing_catalog.yml }

Debug routes

$ php app/console debug:router

Twig functions

Getting link by route name:

{{ page_path('etfostra_content_56') }}

This function return link to page by "Route Name", you can copy it from Page edit form. Function prevent exception when route not found.

Getting link by slug:

{{ page_path_by_slug('any-page-slug') }}

Generates extra query! This function return link to page by Slug, you can edit and copy it on Page edit form. Function prevent exception when route not found.