tdCorePlugin - 0.2.4

Provides basic functionalities enabling TD CMF.

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 Releases Changelog Contribute
Show source

table of contents

tdCorePlugin

The tdCorePlugin is a symfony plugin that provides basic functionalities enabling TD CMF, such as common configuration or random data generation.

This plugin is a part of TD CMF and is based on Doctrine ORM.

Installation

Install the plugin via the subversion repository by executing the following command from the project root directory:

$ svn co http://svn.symfony-project.com/plugins/tdCorePlugin/trunk plugins/tdCorePlugin

or by using the default symfony plugin install command:

$ ./symfony plugin:install -s beta tdCorePlugin

as the actual release is in its beta stage. Run the following command to enable the assets of tdCorePlugin:

$ ./symfony plugin:publish-assets

One of the assets is nice CSS file cooperating with other TD CMF plugins.

Usage

  • This plugin is the main part of the TD CMF and therefore it should be installed as the first one. Other td components will use functionalities provided with tdCorePlugin.

  • Enable the file in your apps/backend/config/view.yml file:

    stylesheets:    [ /tdCorePlugin/css/td_admin.css ]

Configuration

  • td_short_text_sign_count - character count of a short descrtiption of any kind of object used among admin generators (used by tdSubpage, tdGuestbookPlugin, tdAudioPlugin, tdVideoPlugin and so on)

tdConfig

tdConfig is a model representing dynamic configuration options in your symfony project. It is provided with the tdConfig backend module enabing easy configuration options management. Just enable the module in your backend/config/settings.yml file:

enabled_modules: [ ... , tdConfig ]

tdSubpage

tdSubpage is a Sluggable model representing subpages in your symfony project. Enables easy management of pages with dynamic content. Use it in your frontend application - in actions, components and layout templates:

link_to('Example Subpage', 'tdSubpage', $subpage)

Breadcrumbs

This part is based on isicsBreadcrumbsPlugin. It includes a singleton managing breadcrumb items. Displaying breadcrumbs is done using a component. At first, enable the tdBreadcrumb module:

enabled_modules: [ ... , tdBreadcrumb ]

Define the path in your templates:

<?php $breadcrumbs->addItem('My action', 'myModule/myAction') ?>
 
=> Home > My action

If the action is deeper:

<?php $breadcrumbs->addItem('My previous action', 'myModule/myPreviousAction') ?>
<?php $breadcrumbs->addItem('My action', 'myModule/myAction') ?>
 
=> Home > My previous action > My action

Define the path in your actions:

public function executeMyAction()
{
  tdBreadcrumb::getInstance()->addItem('My action', 'myModule/myAction');
 
=> Home > My action

Include the breadcrumbs component (in the layout for instance):

<p id="breadcrumbs">
  You are here :
  <?php include_component('tdBreadcrumb', 'display') ?>
</p>

You can set your own root:

<p id="breadcrumbs">
  You are here :
  <?php include_component('tdBreadcrumb', 'display', array(
    'root' => array('text' => 'Home', 'uri' => '@myHomepage')
  )) ?>
</p>

AJAX backend interface

Some of TD CMF plugins use AJAX actions to provide user-friendly interface (such as tdGuestbookPlugin). Enable the graphics module from tdCorePlugin to enable AJAX actions in other plugins to run correctly:

enabled_modules: [ ... , graphics ]

More about TD CFM AJAX backend feature in my symfony developer blog

sfAdminDashPlugin compatibility

The icons provided with the plugin may be used for sfAdminDashPlugin. To do so, you need to do the following:

  • modify the sfAdminDashPlugin/config/app.yml file, set:

    image_dir: /tdCorePlugin/images/icons/
  • and finally you may use the icons in the app.yml file:

    categories:
      Administration:
        items:
          Newsletter:
            url: newsletter
            image: newsletter.png

Random Data Generator

There is a class in the plugin responsible for generating some random data used for the symfony fixtures. During development phase its essential to see how some mechanisms work when real data is available in the database. Writing the same methods many times is useless - that's where random data generator comes in. an example to generate some data in data/fixtures/sample.yml file is shown below:

<?php $generator = new tdRandomDataGenerator(); ?>
Guestbook:
<?php for($i = 0; $i < 150; $i++): ?>
  guestbook_<?php echo $i ?>:
    author: <?php echo $generator->getRandomName()."\n" ?>
    email: <?php echo $generator->getRandomEmail()."\n" ?>
    http: <?php echo $generator->getRandomHttp()."\n" ?>
    text: <?php echo $generator->getRandomText(mt_rand(20,100)*mt_rand(1,5))."\n" ?>
<?php endfor; ?>