sfSimpleCMSReloadedPlugin - 0.1.1

The sfSimpleCMSReloadedPlugin provides CMS facilities for Symfony 1.4 and Propel 1.5.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Dependencies Releases Changelog Contribute
Show source | Show as Markdown

sfSimpleCMSReloadedPlugin

Overview

This plugin is a reincarnation of the very good Symfony CMS plugin sfSimpleCMSReloadedPlugin provided by Francois Zaninotto, reworked to make it compatible with Symfony 1.4 and some additional libraries:

  • Protoculous library was replace by jQuery 1.4 (via sfJqueryReloadedPlugin)

  • Propel was updated to version 1.5 (via sfPropel15Plugin)

  • TinyMCE was integrated into sfSimpleCMSReloadedPlugin

This plugin allows you to add a simple Content Management System (CMS) to your symfony application with the following features:

  • Uses Javascript and Ajax to provide a neat user experience

  • Edit zones in pages

  • Edit page URL (you can use / in page path)

  • Edit content in the real context ('edit in place')

  • Preview result

  • Create and manage a tree structure for pages

  • i18n ready (the interface is translated)

  • l10n ready (a page can have different versions)

  • support multiple templates

  • Basic publication workflow

  • Breadcrumb navigation

  • User management is controlled through sfGuardPlugin

It is not aimed at replacing full-featured CMS packages, but offers a lightweight alternative for when you build a website that has to contain pages often updated by special users. It is voluntarily simple, and very easy to configure; so it should fulfill most basic CMS requirements.

Please note that this plugin is in active development. If you want to help and improve it, please contact us at www.sysgrade.de.

Screenshots

sfSimpleCMS_1.gif
sfSimpleCMS_2.gif
sfSimpleCMS_3.gif

Requirements

The prerequisites for using the sfSimpleCMS plugin are:

  • As the plugin doesn't contain a user management module, the project where you install it must have a table managing authors, or users (whatever the name), and the related Propel class must have a __toString() method. Both these conditions are satisfied by the sfGuardPlugin, so installing this plugin is a good choice.

  • The page tree strucure uses the nested set capabilities of Propel 1.5. For this reason, the sfPropel15Plugin is necessary for properly using sfSimpleCMSReloadedPlugin.

  • You need a database capable of handling right joins. MySQL, PostGreSQL are fine, SQLite is not enough.

To install the plugin for a symfony project, the usual process is to use the symfony command line:

$ php symfony plugin:install sfSimpleCMSReloadedPlugin

Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's page and extract it under your project's plugins/ directory. You will also have to copy the contents of the myproject/plugins/sfSimpleCMSReloadedPlugin/web/ directory into a myproject/web/sfSimpleCMSReloadedPlugin/ directory ur use the publish-assets task of Symfony:

$ php symfony plugin:publish-assets

Rebuild the model, generate the SQL code for the new tables and insert it into your database:

$ php symfony propel:build-all

Clear the cache to enable the autoloading to find the new classes:

$ php symfony cc

You can load the included fixtures to start using the forum with test data. These are dsigned to be an inline help, so don't hesitate to use them the first time you test the plugin.

$ php symfony propel:data-load --application="frontend" plugins/sfSimpleCMSReloadedPlugin/data/fixtures

Enable the new sfSimpleCMSReloaded and sfSimpleCMSReloadedAdmin modules in your application, via the settings.yml file.

// in myproject/apps/frontend/config/settings.yml
all:
  .settings:
    enabled_modules:        [sfSimpleCMSReloaded, sfSimpleCMSReloadedAdmin](default,)

Start using the plugin by browsing to the admin module's default page:

http://myproject/frontend_dev.php/sfSimpleCMSReloadedAdmin

There, you will be able to create the root page (if you didn't insert the fixtures) and add new pages. You will also be able to access the new pages in edit mode from the admin section.

Basic usage

Pages created by the sfSimpleCMSReloadedPlugin all have a path property. Using this path, you will be able to see the page in the frontend. For instance, if a page is created with the path foo/bar, you will be able to see it by browsing to:

http://myproject/frontend_dev.php/cms/foo/bar

Only published pages are accessible that way.

To edit it, just add a ?edit=true query string to this URL. If the current user has the proper credentials, he will then get access to the edit features:

http://myproject/frontend_dev.php/cms/foo/bar?edit=true

In this mode, all the editable zones of a page can be modified by double-clicking in the zone and changing the content in the form control that appears. Even unpublished pages can be edited that way.

Once the page is edited, you can preview the result by adding preview=true to the query string:

http://myproject/frontend_dev.php/cms/foo/bar?edit=true&preview=true

The editor toolbox will automate all that and, in practice, you will never need to edit the URL.

Usage inside another page

You can choose to add an editable CMS component to an existing template somewhere else in your application. For instance, the home page of a website can be managed by the main/index action and contain an editable part. To achieve this, use the sfSimpleCMSReloaded/embed component in the template as follows:

// in modules/main/templates/indexSuccess.php
<?php include_component('sfSimpleCMSReloaded', 'embed', array('slug' => 'test')) ?>

The page must already exist in order to be embedded, so create it in the sfSimpleCMSReloadedAdmin module first and then include it in the target template.

When you want to edit the zones of the page, just add the ?edit=true query string to the normal URL.

http://localhost/main/index?edit=true

This allows you to use only the content editing part of the plugin and not the page controller part.

Note: This feature is experimental and has not been tested after the move to sfSimpleCMSReloaded; that's why the editor toolbar does not appear in these cases. You can only embed one CMS page per template, and it is not possible to change the template of the CMS page directly from the target template for now.

Slots

The templates of the sfSimpleCMSReloaded module define some slots that you can use inside your layout:

  • sfSimpleCMSReloaded_site_name: Site name, based on the app.yml configuration

  • sfSimpleCMSReloaded_main_navigation: List of level 1 pages

  • sfSimpleCMSReloaded_breadcrumb: Breadcrumb trail of links to the current page

An example layout to display all the information of the template is given below. This template is bundled with a CSS and activated by default in the plugin.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-200000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <?php echo include_http_metas() ?>
    <?php echo include_metas() ?>
    <?php echo include_title() ?>
    <?php include_stylesheets() ?>
    <?php include_javascripts() ?>
    <?php include_slot('auto_discovery_link_tag') ?>
    <link rel="shortcut icon" href="/favicon.ico">
  </head>
  <body>
    <div id="cms">
      <div id="head">
        <div id="site_name">
          <?php if(!include_slot('sfSimpleCMSReloaded_home_link')): ?>
            <?php echo link_to(
              sfConfig::get('app_sfSimpleCMSReloaded_home_link', 'My Swell site'),
              sfSimpleCMSReloadedTools::urlForPage(sfConfig::get('app_sfSimpleCMSReloaded_default_page', 'home')),
              array('class' => 'cms_page_navigation')) ?>  
          <?php endif; ?>

          <?php if(!include_slot('sfSimpleCMSReloaded_tagline')): ?>
            <div id="site_tagline">
              <?php echo sfConfig::get('app_sfSimpleCMSReloaded_tagline', 'All there is to know about [name it](you)') ?>
            </div>
          <?php endif; ?>
        </div>
      </div>

      <?php if(!include_slot('sfSimpleCMSReloaded_main_navigation')): ?>
        <div id="mainNavigation">
          <?php include_component('sfSimpleCMSReloaded', 'mainNavigation', array('page' => $sf_request->getAttribute('page'), 'culture' => $sf_request->getAttribute('culture'))); ?>
        </div>
      <?php endif; ?>  

      <div id="content" class="<?php echo $sf_request->getAttribute('page')->getTemplate() ?>" >
        <?php if(!include_slot('sfSimpleCMSReloaded_breadcrumb')): ?>
          <?php include_component('sfSimpleCMSReloaded', 'breadcrumb', array('page' => $sf_request->getAttribute('page'), 'culture' => $sf_request->getAttribute('culture'))) ?>
        <?php endif; ?>

        <?php echo $sf_data->getRaw('sf_content') ?>
      </div>
    </div>
    <?php if(!include_slot('sfSimpleCMS_footer_message')): ?>
      <div id="footer_message">
        <?php echo sfConfig::get('app_sfSimpleCMSReloaded_footer_message', 'Powered by <b>sfSimpleCMS</b> and '.link_to(image_tag('/sfSimpleCMSReloadedPlugin/images/symfony_button.gif', 'align=absmiddle'), 'http://www.symfony-project.com')) ?>
      </div>
    <?php endif; ?>
  </body>
</html>

To deactivate this layout, turn use_bundled_layout to false in your app.yml (see below).

Configuration

app.yml

Some of the features of the plugin can be altered by configuration. To do so, add some of the following lines to your application's app.yml:

all:
    sfSimpleCMSReloaded:
        default_text:           '[text here](add)'   # Default text for page editable parts
        routes_register:        on                  # Use the plugin's routes 
        rich_editing:           off                 # Use TinyMCE for rich text editing
        tinymce_options:                            # Additional TinyMCE initialization options
        default_page:           home                # Slug (=path) of the default root page
        use_bundled_layout:     true                # Use the layout bundled with the plugin (allows native display of navigation menu and breadcrumb)
        use_bundled_stylesheet: true                # Use the stylesheet bundled with the plugin (only makes sens if you use the bundled layout, too)
        home_link:              My swell site       # What is displayed on the top right corner of the pages (can be HTML code)
        tagline:                All there is to know about [name it](you)
        footer_message:         Powered by sfSimpleCMS and symfony
        max_pages_in_list:      5                   # Maximum number of links displayed in an internal list of links
        use_l10n:               true                # Enable multiple versions for a single page
        escaping_strategy:      ESC_RAW             # How content entered in the CMS interface must be escaped. Leave at ESC_RAW for no escaping
        localizations:          [de](en,)            # If l10n is enabled, list of cultures in which pages are available
        default_culture:        en                  # If l10n is not enabled, default culture for pages
        editor_credential:                          # Name of the credential required for page editing (leave blank for free editing)
        publisher_credential:                       # Name of the credential required for page publishing (leave blank for free publishing)
        templates:                                  # Available templates 
          simplePage:           Simple Page         #   the key is the name of a template which must be present in modules/sfSimpleCMS/templates/
          home:                 Home                #   the value is the name under which the template is presented in lists
        slot_types:                                 # Available slot types
          Text:                 Simple text
          RichText:             Rich text
          Php:                  PHP code
          Image:                Image
          Modular:              List of components

Routing rules

The plugin comes with a few routing rules, defined in plugins/sfSimpleCMSReloadedPlugin/lib/routing/sfSimpleCMSReloadedRouting:

  • sf_cms_delete

  • sf_cms_toggle_publish

  • sf_cms_show

If you want to use your own routes instead, turn the routes_register parameter to off in the app.yml.

Templates

The plugin is bundled with a few basic templates, but you will definitely need to add your own templates.

CMS templates are files located under the sfSimpleCMSReloaded module's templates/ directory, with a name ending with Template.php. A template must include the sfSimpleCMSReloaded helper group and call the include_editor_tools() helper at the bottom.

As for page zones, you will need two more helpers to manipulate them:

  • sf_simple_cms_has_slot($slot_name): returns true if a page slot is set, false otherwise
  • sf_simple_cms_slot($slot_name, $default text): includes the slot if in view mode, or the editable version of the slot if in edit mode.

The possible values for the slot name are currently limited to: Title, Slot1, Slot2, Slot3, Slot4.

TODO

  • Beautify admin interface
  • Optimize queries for breadcrumb and navigation to retrieve title in a single query
  • Add a 'type' column to the Page object to deal with pages not handled by the CMS controller, but that must appear in the navigation (mostly internal and external links)
  • Solve the orphan slots problem
  • Change Image slot type to a list of images (cf. Modular slot type)
  • Published status per localization
  • Add more templates
  • Add more components and partials to be used in templates
  • Refactor the sfSimpleCMSReloaded action code to make it DRYier (use mixins?)
  • Better integration with sfGuard
  • Package with other plugins into an application

Changelog

2011-06-18 | 0.1 Beta

  • Initial release of sfSimpleCMSReloadedPlugin after move from sfSimpleCMSPlugin to support Symfony 1.4