smileys Add smileys to comment/posts textareas.

  1. Requirements
  2. Usage

This extension allows you to add clickable smileys for comments/posts forms, so that when pressing them they will be inserted in the content of the given textarea.
Also, the extension offers a helper class to parse the smiley codes into images so that before saving the comment/post to database, you can parse the content, and replace the smileys codes with actual images.
More than this, you can create groups of smileys and use them in different textareas.
Every group of smileys, has it's own configuration file, which allows you to specify the code for your smiley and the image name/width/height/title/alt.

With other words, if you need to add smileys to a textarea, this is the extension you need.


Tested on Yii 1.1.7


This is how you can use this extension, bellow the defaults are shown:

// first, add a textarea:
<textarea name="textarea" id="textarea"></textarea>

//then, call the widget
<?php $this->widget('application.extensions.smileys.SmileysWidget',array(                    
   'group'=>'default', // the group of smileys to be shown                     
   'cssFile'=>'smileys.css', // the file containing the CSS 
   'scriptFile'=>'smileys.js',// javascript code for inserting the smileys into textareas    
   'containerCssClass'=>'smileys',// the CSS class that wraps all smileys
   'wrapperCssClass'=>'smiley', // the CSS class that wrapps a single smiley                        
   'textareaId'=>'textarea', // the ID of the textarea where we will put the smileys
   'perRow'=>0,// If this value is greather than 0, after $perRow smileys, a line break will be inserted. 
   'forcePublish'=>false,// set to true for one time, after you've added a new smiley group so that the group gets published to assets directory

The above code, will generate the smileys and when each of them is clicked, is inserted into the textarea. Next, after the user submits the form, we can parse the smileys into images, like:


As you see the process is simple enough.
If you need to create other smiley groups, for your own use, just take the default or the light groups as an example and you will see how easy is to create and use your own groups of smileys.

Before posting questions here, take a look into the extension files as they are commented very well. If you still have doubts after this, please ask here any question you might have.

Also, worth noticed that this extension has been created a few hours ago, and i already implemented it in two of my projects, if you find any bugs, or you have suggestions, don't hesitate to let me know.

3 0
1 000 downloads
Yii Version: 1.1
License: (not set)
Category: User Interface
Developed by: twisted1919
Created on: Apr 13, 2011
Last updated: 10 years ago


show all

Related Extensions