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.
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->renderPartial( 'application.extensions.ddnotes.views.notes', array( 'model'=>$model, 'form'=>$form ) );
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): ?> <h3> <?php echo CHtml::encode(Yii::t('ddnotes', '1#One note for item {recordName}|n>1#{notesCount} notes for item {recordName}', array( $model->notesCount, '{notesCount}'=>$model->notesCount, '{recordName}'=>$model->recordName))); ?> </h3> <?php $this->renderPartial('application.extensions.ddnotes.views._notes', array( 'model'=>$model, )); ?> <?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.
Total 1 comment
I solved these by implementing CTimestampBehavior on DDNotesBehavior:
Leave a comment
Please login to leave your comment.