sgBannerRotatorPlugin - 1.0.1

Banner Rotator plugin

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

sgBannerRotator plugin

The sgBannerRotator is a simple symfony plugin that rotates a banner image in a web page.

sgBannerRotator provides a helper to create the HTML tag to insert the image. With the help of a set of CSS classes the image is rotated in the page.

Installation & Usage

  • Install the plugin

    $ symfony plugin:install sgBannerRotatorPlugin
    
  • Enable Plugin (Only for Symfony 1.2 and above)

    Modify config/ProjectConfiguration.class.php

    public function setup()
      {
        // for compatibility / remove and enable only the plugins you want
        $this->enableAllPluginsExcept('sfDoctrinePlugin');
     
        // or
     
        $this->enablePlugins(array('sfPropelPlugin', 'sgBannerRotatorPlugin'));
        $this->disablePlugins(array('sfDoctrinePlugin'));
     
      }        
  • Set up CSS

    The helper creates a div html tag where the image will be placed using the background-image css property. Add the following CSS classes to your CSS file to define the size of the banner and the banner images:

    /* defines the size of all the banners */
    .bannerHome {
        width: 926px;
        height: 289px;
    }
     
    /* define banners' location */
    .banner0 {
        background-image: url(/images/banner1.png);
    }
    .banner1 {
        background-image: url(/images/banner2.png);
    }
    .banner2 {
        background-image: url(/images/banner3.jpg);
    }
  • Add helper to action template

    In your indexSuccess.php template add the following

    <?php use_helper( 'BannerRotator'); ?>
    <!-- HTML code -->
    <?php echo rotate_banner( $banners, array('class' => 'bannerHome') ) ?>
    <!-- more HTML code -->    

    In your actions.class.php define the $banners array with the list of urls where the banners should link to.

    public function executeIndex()
      {
            $this->banners = array(
            '/url1',
            '/url2',
            'http://www.symfony-project.org/',
            );        
      }

    That's it!

TODO

  • Implement view / click counts
  • Implement css-less method
  • Contact me for any other requirements/ideas