Yii 1.1: yiidecoda

decoda integration

Decoda is a lightweight class that extracts and parses a custom markup language; based on the concept of BB code. Decoda supports all the basic HTML tags and manages special features for making links and emails auto-clickable, using shorthand emails and links, and finally allowing the user to add their own code tags.


Download and unpack source into protected/extensions/ folder.

Set component in config

    'decoda' => array(
        'class' => 'ext.decoda.YiiDecoda',
        'defaults' => true,

Parsing string

$string = '[b]BB Code[/b]';
$parsedString = Yii::app()->decoda->parse($string);
echo $parsedString; // <b>BB Code</b>

You can use DecodaValidator or filter for your model

public function rules()
    return array(
        // DecodaValidator
        array('content', 'ext.decoda.DecodaValidator', 
          'errorTypes' => array(Decoda::ERROR_NESTING, Decoda::ERROR_SCOPE), 
          'useParsed' => true),
        array('content', 'filter', 'filter' => array(Yii::app()->decoda, 'parse')),


Configuration example with all available properties (values ​​are initialized in the order in which they are listed here)

    'decoda' => array(
        'class' => 'ext.decoda.YiiDecoda',
        'vendorPath' => 'ext.decoda.vendors.decoda',
        'defaults' => true,
        'addFilters' => array('Code', 'Default', 'List', 'Quote'),
        'removeFilters' => array('Code', 'Default'),
        'disableFilters' => false,
        'addHooks' => array('Emoticon', 'Clickable'),
        'removeHooks' => array('Censor'),
        'disableHooks' => false,
        'brackets' => array('{', '}'),
        'locale' => 'en-us',
        'shorthandLinks' => true,
        'useXHTML' => false,
        'whitelistTags' => array('code', 'b'),
        'convertWhitespaces' => true,
        'disableParsing' => false,



- update decoda, version 3.3.1
- removed "useTextHighlighterForCode" property
- added "convertWhitespaces" property

- initial version

Total 9 comments

#15030 report it
fantgeass at 2013/09/30 08:40am
About update

Sorry, I don't use PHP anymore(switched to Ruby).

#15011 report it
Tpona at 2013/09/28 06:02pm
update please

could you make update plugin with latest version of decoda sources?

#13171 report it
hakd at 2013/05/10 07:13am
Decoda 6.01 is already released

Decoda 6.01 is already released http://milesj.me/code/php/decoda

It should be nice to update this extension.

#13128 report it
EndErr at 2013/05/07 02:17am
code snippets / iframes

How to skip parsing blocks of code to be able to include some additional code or scripts, i.e. youtube videos or google maps?

#12819 report it
v_bogdan at 2013/04/13 11:38am
links doesn't work

links doesn't work, bbcode tags removing and that's all. removeFilters doesn't help.

#11793 report it
kernel32ddl at 2013/02/04 07:56am
Disable links

Hi! Is any possibility to disable links parsing, to prevent converting



<a href="http://site.com">http://site.com</a>

Update! To disable filter for parsing URLs in decoda config we need add:

'removeFilters' => array('Url'),
#9260 report it
Cstdenis at 2012/08/01 02:22am
missing decoda folder in zip.

v1.1 zip doesn't have a decoda folder at the root.

You have to create it manually in extensions then extract into it.

#7901 report it
kazio at 2012/04/25 08:54am

in 5.3 environment i had to change from

Yii::registerAutoloader(array('Decoda', 'loadFile'), true);


Yii::registerAutoloader(array('Decoda', 'loadFile'), false);

for autoloader in YiiDecoda.php.

#7899 report it
kazio at 2012/04/25 07:32am
it does not work for me

it does not work for me, In EmotionHook.php

protected function _emoticonCallback($matches)
        $smiley = trim($matches[0]);
        if (count($matches) == 1 || !isset($this->_map[$smiley])) {
            return $matches[0];

but count($matches) is 1 for matched icon.

so emoticon is not diplayed.

i had to change

if (!isset($this->_map[$smiley])

im using php 5.4

Leave a comment

Please to leave your comment.

Create extension