Yii 1.1: oc-auto-tag

Auto tags generation using Open Calais
1 follower

OCAutoTag Component is a useful extension to auto generate tags from Calais service. This extension is based on Open Calais Tags PHP class written by Dan Grossman, see http://www.dangrossman.info/open-calais-tags/.

Currently only English and French are supported by Calais.




  • Yii 1.03 or above (only tested on Yii 1.03)


  • Extract the release file under protected/extensions


See an eample used in Blog Demo:

In config file main.php, add to component:

              'oc_api_key'=>'calais_api_key', // required, add your Calais API key here
              'tag_delimiter'=>',', // Optional, set tag delimiter here

Modify actionCreate() action in PostController.php file:

public function actionCreate()
            $post=new Post;
              $oc = Yii::app()->OCAutoTag; // Get an OCAutoTag instance
              $auto_tag = $oc->getTags($_POST['Post']['content']); // Get tag in string by sending in post content
                $_POST['Post']['tags'] = !empty($_POST['Post']['tags'])?$_POST['Post']['tags'].$oc->getTagDelimiter().$auto_tag:$auto_tag; // Append auto generated tags to user input tags if $auto_tag is not empty
                else if(isset($_POST['submitPost']) && $post->save())

Change Log

April 2, 2009

  • V0.1 Initial release.

Be the first person to leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: will
  • Category: Others
  • Votes: +1
  • Downloaded: 335 times
  • Created on: Apr 2, 2009
  • Last updated: Apr 2, 2009