Taggable Behaviour This extension allows active record model to manage tags.
#21
Posted 04 March 2011 - 05:01 AM
That means you don't have $model->tags. How you've attached behavior?
#22
Posted 04 March 2011 - 05:08 AM
samdark, on 04 March 2011 - 05:01 AM, said:
That means you don't have $model->tags. How you've attached behavior?
I have debugged this, $model->tags returns an Array of Tag objects...
In my model I have:
public function behaviors() {
return array(
'tags' => array(
'class' => 'application.extensions.taggable.ETaggableBehavior',
'tagTable' => 'Tag',
'tagBindingTable' => 'Event_has_Tag',
'tagBindingTableTagId' => 'tag_id',
'modelTableFk' => 'event_id',
'tagTablePk' => 'id',
'tagTableName' => 'name',
'scope' => array(
'condition' => 'public = 1 OR user_id ='. Yii::app()->user->id,
),
'insertValues' => array(
'user_id' => Yii::app()->user->id,
),
)
);
}
#25
Posted 10 August 2011 - 01:58 AM
the tag_entity to record tag_id, entity_id and entity_type, that make tag fits any other entity(table)
and I've modified class for our use, by adding variable named 'insertBidingValues' and related snappet
but 'insertValues' is not work
and I've modified class for our use, by adding variable named 'insertBidingValues' and related snappet
but 'insertValues' is not work
public function behaviors(){
return array(
'tags'=>array(
'class'=>'ext.yiiext.behaviors.model.taggable.EARTaggableBehavior',
'tagTable'=>'tag',
'tagBindingTable'=>'tag_entity',
'modelTableFk'=>'entity_id',
'tagTablePk'=>'id',
'tagTableName'=>'title',
'tagBindingTableTagId'=>'tag_id',
'cacheID'=>'tag_cache',
'createTagsAutomatically'=>true,
'insertValues'=>array(
'parent_id'=>0
),
'insertBindingValues'=>array(
'entity_type'=>'article'
),
)
);
}
#26
Posted 07 April 2012 - 04:08 PM
Is this still active? Anybody using it successfully? I am trying to download the code but seems only source code is available and no a release version yet. Anybody can advice? I am looking for an extension or behavior for Yii that let me manage Tags as you exposed. Thanks.
#28
Posted 23 April 2012 - 05:33 AM
I've used it successfully in several projects.
"Less noise - more signal"
#29
Posted 12 June 2012 - 01:04 PM
Hi,
Thanks for the great extension.
I'm trying to use it but getting a error.
I'm using Postgresql 8.4
Thanks for all the help.
Thanks for the great extension.
I'm trying to use it but getting a error.
// Post.php
public function behaviors()
{
return array(
'tags-with-model'=>array(
'class'=>'ext.taggable.EARTaggableBehavior',
'tagTable'=>'tag',
'tagModel'=>'Tag',
'tagBindingTable'=>'post_tag',
'modelTableFk'=>'post_id',
'tagTablePk'=>'id',
'tagTableName'=>'name',
'tagTableCount'=>'count',
'tagBindingTableTagId'=>'tag_id',
),
);
}
// PostController.php
public function actionCreate()
{
...
try
{
$model->setTags('test')->save('false');
...
...
}
I'm using Postgresql 8.4
// tag.sql DROP TABLE IF EXISTS tag CASCADE; DROP TABLE IF EXISTS review_tag CASCADE; CREATE TABLE tag ( id serial, name character varying(255) NOT NULL, count integer DEFAULT 1, PRIMARY KEY (id), CONSTRAINT tag_name UNIQUE (name) ); CREATE TABLE post_tag ( post_id integer NOT NULL, tag_id integer NOT NULL, PRIMARY KEY (post_id, tag_id) );
// application.log 2012/06/12 18:49:22 [error] [application] actionCreate(); exception 'PDOException' with message 'SQLSTATE[42602]: Invalid name: 7 ERROR: invalid name syntax' in /var/www/yii-1.1.10.r3566/framework/db/CDbConnection.php:535
// postgresql log 2012-06-12 18:49:22 WEST ERROR: invalid name syntax 2012-06-12 18:49:22 WEST STATEMENT: SELECT CURRVAL($1) 2012-06-12 18:49:22 WEST ERROR: current transaction is aborted, commands ignored until end of transaction block 2012-06-12 18:49:22 WEST STATEMENT: DEALLOCATE pdo_stmt_0000000f
Thanks for all the help.
#30
Posted 12 June 2012 - 05:12 PM
I I enabled postgresql parameter logging.
2012-06-12 22:40:22 WEST DETAIL: parameters: $1 = 'tag_id_seq' 2012-06-12 22:40:22 WEST LOG: duration: 0.022 ms execute <unnamed>: SELECT CURRVAL($1) 2012-06-12 22:40:22 WEST DETAIL: parameters: $1 = 'tag_id_seq' 2012-06-12 22:40:22 WEST LOG: duration: 0.051 ms statement: DEALLOCATE pdo_stmt_00000014 2012-06-12 22:40:22 WEST LOG: duration: 0.062 ms parse <unnamed>: SELECT CURRVAL($1) 2012-06-12 22:40:22 WEST ERROR: invalid name syntax 2012-06-12 22:40:22 WEST STATEMENT: SELECT CURRVAL($1) 2012-06-12 22:40:22 WEST ERROR: current transaction is aborted, commands ignored until end of transaction block 2012-06-12 22:40:22 WEST STATEMENT: DEALLOCATE pdo_stmt_0000000f 2012-06-12 22:40:22 WEST LOG: duration: 0.040 ms statement: ROLLBACK
#31
Posted 19 June 2012 - 03:04 PM
Ok,
My problem is on ETaggableBehavior->afterSave, on line 373:
My problem is on ETaggableBehavior->afterSave, on line 373:
$tagId = $this->getConnection()->getLastInsertID();
#32
Posted 20 June 2012 - 12:27 AM
If I change that line to:
it works.
what could be the issue?
$tagId = $this->getConnection()->getLastInsertID('tag_id_seq');
it works.
what could be the issue?
#33
Posted 30 January 2013 - 10:03 AM
Can anyone recommend an approach to save the user who set a tag and when it was set?
I'm thinking that the best approach is a custom TaggableBehavior class that overrides afterSave() and saves the additional info using a technique similar to $insertValues in this block of code:
I'm thinking that the best approach is a custom TaggableBehavior class that overrides afterSave() and saves the additional info using a technique similar to $insertValues in this block of code:
// bind tag to it's model
$builder->createInsertCommand(
$this->getTagBindingTableName(),
array(
$this->getModelTableFkName() => $this->getOwner()->primaryKey,
$this->tagBindingTableTagId => $tagId
)
)->execute();

Help














