How to use PrettyPhoto Extension in Yii

It is so simple to use PrettyPhoto Extension in Yii Framework.

How to Install

Unzip the contents of the downloaded package below and copy its contents into your application’s protected/extensions folder.

How to Use

Once we have move the contents of the zipped file into the extensions folder we are ready to go. Use it at your own will into your views like this:

  1. <?PHP
  2. Yii::import(‘ext.jqPrettyPhoto’);
  3. jqPrettyPhoto::addPretty(‘.gallery a’,jqPrettyPhoto::PRETTY_GALLERY,jqPrettyPhoto::THEME_FACEBOOK);
  4. ?>

Wow! That was easy! Please allow me to explain the addPretty function. It comes with three parameters:

1) element/s selector: the JQUERY SELECTOR to the links you want to set pretty photo to. In the example above I had the following on the view’s HTML:

  1. <div class=“gallery”>
  2. <a href=“URL_TO_IMAGE_TO_OPEN”><img src=“URL_TO_IMAGE_TO_SHOW”/></a>
  3. </div>

2) The second parameter is of the value jqPrettyPhoto::PRETTY_GALLERY or jqPrettyPhoto::PRETTY_SINGLE, which tells the extension whether the selector will be a list of a gallery images or just a single file.

3) The third one is what theme to use -please refer to jqPrettyPhoto.php’s code to see more options on this one.
Download Now

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>