Giter Club home page Giter Club logo

staticpagebundle's Introduction

StaticPageBundle

Installation

Install bundle through composer:

composer.phar require sokil/static-page-bundle

Add bundle to AppKernel:

<?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.

Routing

To enable default routing configuration just add routing.yml to you routes config app/config/routing.yml:

static_page:
    resource: "@StaticPageBundle/Resources/config/routing.yml"
    prefix:   /

Or add your own routes for required actions.

To route any unexisted url to static page handler, you need to add some configuration to app/config/config.yml:

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:

# 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:

{% import "@FrontendBundle/Resources/views/macro.html.twig" as frontend %}
{% import "@StaticPageBundle/Resources/views/macro.html.twig" as staticPageSpa %}

{{ staticPageSpa.jsResources() }}

<script type="text/javascript">
    (function() {
        // app options
        var options = {{ applicationData|json_encode|raw }};
        // router
        options.routers = [
            StaticPageRouter
        ];
        // requirejs
        options.requireJs = [
            StaticPageRequireJsConfig
        ];
        window.app = new Application(options);
        window.app.start();
    })();
</script>

Deploy

If you want to use embedded editor, you need to setup SPA.

You need to execute grunt tasks to build SPA:

npm install
bower install
grunt

Bundle uses assetic bundle, so you need to register it in assetic config:

assetic:
  bundles:
    - StaticPageBundle

staticpagebundle's People

Contributors

sokil avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.