sfEleAdminI18n plugin
The sfEleAdminBannerPlugin is a symfony plugin that provides a simple tool for administrating banner placement.
It consists in one module called 'sfEleAdminBanner' for content administration and one helper 'sfEleBannerHelper'.
Installation
Install the plugin
$ symfony plugin:install sfEleAdminBannerPlugin
Publish plugin assets (When using pear install on unix, you don't have to follow this step)
$ symfony plugin:publish-assets
Rebuild your model
$ symfony propel:build-model
$ symfony propel:build-sql
$ symfony propel:build-forms
$ symfony propel:build-filters
Update your database tables by starting from scratch (it will delete all the existing tables, then re-create them):
$ symfony propel:insert-sql
or you can just create the new tables by using the generated SQL statements in
data/sql/plugins.sfEleAdminBanner.lib.model.schema.sql
Set the module enabled in your settings.yml (usually located in /apps/<your_app>/config/settings.yml)
all:
.settings:
enabled_modules: [<your_enabled_modules>, sfEleAdminBanner]
Clear your cache
$ symfony cc
Configuration
You can define your banners positions and pages in app.yml
all:
sf_ele_admin_banner:
positions: [] # array containing available positions
pages:
<id>: # id for the pages array
title: <value> # value containing the I18N string translation for showing this page on administration module
positions: [<positions>] # array containing the positions the page use acording to positions array
module: <module> # module name that banner should appear (optional)
action: <action> # action name that banner should appear (optional)
<id2>: # can add as many IDs as needed
...
The position can be interpreted as different ways:
- A location of banner in a page;
- A banner size;
- A kind of banner content;
- etc.
The page works as a filter for positions. The position is displayed only is set inside a page. When you set a page,
you're saying that the positions set in this page should appear in the desired module and action. You can also set that
position can appear in:
- All modules and all actions;
- One module and all actions;
- One module and one action;
To set a position for all modules or all actions you can use the null value ~. But the position will only appear when you
have a calling inside you page to sfEleBannerHelper function include_banner_position (see sfEleBanner Helper).
Administration Design
Administration is suited to use sf_admin theme (or advanced theme sf_ele_admin)
Using Administration Module
The administration module works like a crud. There you can edit the banner content in HTML Body field, set as active or
inactive and choose the positions that banner should appear and respective pages (according to app.yml configuration).
sfEleBanner Helper
The helper contains only one function called include_banner_position. This functions has two parameters:
position: string containing the position name (according to app.yml config);
random: boolean that indicates if you want to get the banner by order of creation or random. Default value is set to true.
Example of use (app.yml):
all:
sf_ele_admin_banner:
positions: [top, content_middle, banner150x100]
pages:
all_pages:
title: All Pages
positions: [top, banner150x100]
module: ~
action: ~
main_page:
title: Main Page
positions: content_middle
module: content
action: index
In this app.yml file we set 3 different banner positions top, content_middle and banner150x100. According to pages
configuration, the top and banner150x100 positions will be displayed in all pages that call them and the content_middle
should be displayed only in the module content and action index.
Example of php file:
...
<body>
<div id="top_banner">
<?php echo include_banner_position("top", true) ?>
</div>
...
<div id="content_banner">
<?php echo include_banner_position("content_middle") ?>
</div>
...
<div id="footer_banner">
<?php echo include_banner_position("banner150x100") ?>
</div>
...
</body>
According to previous app.yml file configuration, this page should always display the banner top and banner150x100, and the
banner content_middle should appear only if this page is from module content and action index.
Author