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

  1. Requirements
  2. Installation
  3. Usage
  4. Resources
  5. History

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.

Requirements

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

Installation

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.

Usage

Model

Include the DDNotes behavior in your model class:

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

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:

[html]
<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.

Resources

History

  • 2011-09-29
    V0.1 Initial version
3 0
3 followers
464 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: jwerner
Created on: Sep 29, 2011
Last updated: 12 years ago

Downloads

show all

Related Extensions