Yii 1.1: ddnotes

Provides a CActiveRecord behaviour to show or add notes attached to a record

The DDNotes extension provides a behaviour for a CActiveRecord to show notes attached to the record and to add new notes.

All notes are stored in one database table.


  • Yii Framework 1.1 or above (tested with V1.1.8)
  • Having authentificated users (see Yii blog demo)


Extract the downloaded extension archive under the extensions directory.

Create the neccessary table for the notes items. Run the schema_sqlite.sql against your database.

Optionally, move the message files in extensions/ddnotes/messages to your protected/messages tree.



Include the DDNotes behavior in your model class:

// {{{ behaviors
public function behaviors()
    return array(
        'notesBehaviour' => array(
            'class' => 'application.extensions.ddnotes.DDNotesBehavior',
} // }}}


In your _form view, add this code:


This will show a list off all notes attached to the current record, and also a small form snippet to add a new note.

In your item view template, add this code:

<div id="comments" style="margin-bottom:10px;">
    <?php if($model->notesCount>=1): ?>
        <?php echo CHtml::encode(Yii::t('ddnotes',
        '1#One note for item {recordName}|n>1#{notesCount} notes for item {recordName}',
            '{recordName}'=>$model->recordName))); ?>
    <?php $this->renderPartial('application.extensions.ddnotes.views._notes',
    )); ?>
    <?php else : ?>
    <?php echo CHtml::encode(Yii::t('ddnotes','No notes yet.')); ?>
    <?php endif; ?>
</div><!-- }}} End Notes -->

This will display a list of the notes attached to the currently displayed record.



  • 2011-09-29
    V0.1 Initial version

Total 1 comment

#11495 report it
PrplHaz4 at 2013/01/16 07:43pm
Problems with timestamps
  • tsCreated is not saved in MySQL datetime format, so it doesn't save
  • tsUpdated is not utilized
  • _notes view does not display time correctly from MySQL time format

I solved these by implementing CTimestampBehavior on DDNotesBehavior:

public function behaviors(){
    return array(
        'CTimestampBehavior' => array(
            'class' => 'zii.behaviors.CTimestampBehavior',
            'createAttribute' => 'tsCreated',
            'updateAttribute' => 'tsUpdated',
//_notes.php use this instead

Leave a comment

Please to leave your comment.

Create extension