Download the PHP package eight/page-bundle without Composer
On this page you can find all versions of the php package eight/page-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eight/page-bundle
More information about eight/page-bundle
Files in eight/page-bundle
Package page-bundle
Short Description Symfony CMS Bundle for full page editing
License MIT
Homepage https://github.com/matteocaberlotto
Informations about the package page-bundle
EightPageBundle
This bundle allows you to build cms editable pages within minutes without changing too much usual symfony development process. Supports Symfony 2+ up to 3.3 (symfony 4.0 is in roadmap). Just be sure to select the proper version.
- for Symfony and Twitter Bootstrap
- for Symfony and Twitter Bootstrap
Roadmap:
- some more tests
- ease admin bundle switching
- ease storage switching
- symfony 4 compatibility
Features:
- fully editable page properties (title, url, meta, og, ...) inside admin section
- fully editable html layout, blocks tree with predefined widgets inside admin section
- auto form building for in-place content editing
- yml content loader/exporter for programmatic page editing
- very light and easy to admin!
Installation
You can clone the sandbox from its repository https://github.com/matteocaberlotto/eight-cms or follow instructions below if you need to install CMS on existing project.
-
require via composer
- composer require eight/page-bundle
-
install and configure dependencies (refer to each installation documentation)
- sonata admin bundle (for admin structure/navigation)
- raindrop routing bundle (for dynamic routing)
- fos user bundle (this is not strictly required)
- symfony/templating (only for some symfony versions)
- symfony/assetic-bundle
- you will also need to manually include twitter bootstrap assets (3.3. for 1.0. and 4. for 1.3.)
-
add following lines to config.yml if you need to configure one or more of the following features:
- general encoding
- default title
- default description
- locales
- homepage redirect after locale has been detected
- default controller (you can bind custom controllers to a page, else the default will be used)
- default layout
- assets to be loaded in each page
- admin assets to be appended when editing
- metatags you want to edit in admin area
- Update database with
Creating pages:
To create a page you need at least 1 layout and 1 block. A layout is simply a simfony page with at least 1 call to which is the twig function that dinamically appends blocks. You can have multiple insertion points, just be sure to name each one by passing the label as parameter. EG: . Once the insertion point is present, in the admin section you can append one of the widgets defined via configuration.
An example layout could look like this:
You can use to dinamically render metatags edited in the admin section. to dinamically append stylesheet assets to the page (just read on to know how to). to dinamically append html editable blocks to the page. to dinamically append html editable blocks to all of the pages where this slot is rendered. to dinamically append javascript assets.
By default no widget is added, but you can use some defaults by simply adding this line to config.yml:
To nest widgets, call method inside a block template. Please note the 'current_block' variable as parameter which is mandatory. You can also add a label as second parameters to append multiple childrens to differents position of the current block. E.G.:
This block template allows you to append elements to both the left and right column (without mixing).
A widget is like a symfony controller with some more features: a predefined layout and an array of editable variables. Each variable has its own database slot (even if not populated). You have to use it as a symfony controller, eg:
This widget has 1 "normal" variable and 3 editable variables: the first is a variable as you would declare in a symfony controller and it will be passed with its value without references to database. Instead all others will be filled with database values: the first editable one is a simple label (255 max chars), the second is an icon you can select among all fontawesome 4.7 list and the last is a link to an entity of the specified class. More types are available.
In order to create a widget you must implement all the abstract methods, a unique name to be identified and a layout. You must also register its class with the tag eight_page.widget
.
To sum up, widget creation consists of 3 steps:
- create widget class
- create widget layout
- register widget class with tagging
that's all.
Whenever you want to add the same block to multiple pages, use the method (which also accept a single string identifier as parameter). For example, you can add a static block of type "raw html" to all pages and fill with google analytics script of facebook sdk or anything that is supposed to be rendered in all pages.
In order to make jquery ui sortable feature work fine, there is one single requirement: each widget template must have a single parent html tag (usually a div or a span).
Sometimes you may need to adjust little css in administration in order to handle more complex layout editing situations. The editor adds a lot of custom classes in the admin section you can use to drive your rendering. The "preview" button will remove the editing classes from the page so you can check the page result on the fly. You can also bind your own javascript "plugins" so they will be reloaded on blocks modification, eg:
Note that everything else works the same as symfony standard so you can mix static contents with CMS ones (just note that the dinamic router of the cms has precedence in case of identical route paths).
Twig helpers:
- : renders page title taken from cms page.
- : renders page encoding.
- : renders page metadata as edited in the admin.
- : renders all page blocks of given type.
- : renders all child blocks of given block and type.
- : renders all static page blocks of given type for current page.
- : renders all stylesheets of the current page and child blocks.
- : renders all javascripts of the current page and child blocks.
- : renders page body class.
- : returns 'active' if current path name is $name.
- : returns true if test is contained in the current host.
- : returns true if current path is equal to path or an index of it (accepts a label or an array).
- : returns the string if current route is in routes else an empty string.
- : a simple helper to count unrelated things at runtime. You can increment the counter for a given label or get its value.
- : same as twig method for cms pages. It will search for a page with name $path, path $path or tag $path.
- : returns the title of a page.
More features:
You can also add js() or css() method to any widget to append assets dynamically. Just return an array of valid assets path.
Prefer helper in place of twig function to link to cms pages. It does exactly the same but with a little enhancement: you can also "search" for a page based on its tagging.
EG: will link to a page tagged "homepage.
Recommendations
Try to avoid adding new variables to existing widgets as this could lead to twig errors (though most are handled). A good habit could be to always add an variable to add custom classes to any block.
Sandbox
Take a look at sandbox installation at https://github.com/matteocaberlotto/eight-cms.
Demo
A working demo version with accessible admin interface is available at http://cms.eightweb.it