Cannot add setAttribute() to tags

Permalink 1 user found helpful
i just trying to auto add tags, but not work, its not save

$p->setAttribute('tags',  'saveMe');


but if i use my own atribut 'is_featured', it save
$p->setAttribute('is_featured', '1');


how to add attribut tags automatically?

fastcrash
 
fastcrash replied on at Permalink Reply
fastcrash
thank for reply mnkras
but still not work
$p->setAttribute('tags',  array('saveMe'));
$p->setAttribute('is_featured', '1');


the value of tags attribut not save, but the is_featured value is save.
i wonder why..

can we insert it manually? i dont know what function to save it
Mnkras replied on at Permalink Reply
Mnkras
after doing some digging, it seems that you cannot add new tags that way, only set existing ones,

unfortunately I don't have to time right now to dig any deeper,

sorry,

Mike
fastcrash replied on at Permalink Reply
fastcrash
okay mike, thanks for digging :)
Korvin replied on at Permalink Reply
Korvin
Fixed
fastcrash replied on at Permalink Reply
fastcrash
Ha haa.. that puny pop-up
do u want my cookie?
mkly replied on at Permalink Best Answer Reply
mkly
TO ADMINS: CLOSING WINDOWS ON ESCAPE IN THIS FORUM IS REALLY PAINFUL FOR VIM USERS lol

anyhow. It's a block right? I think you can just use the tag block controller.

Loader::block('tags');
$tags_block_controller = new TagsBlockController();
$pg = Page::getCurrentPage();
$args['targetCID'] = $pg->getCollectionID();
$args['title'] = 'Tag Name';
//I'm not sure if you need this.
Loader::model('attribute/categories/collection');
$ak = CollectionAttributeKey::getByHandle('tags');
$nvc = $pg->getVersionToModify();
$ak->saveAttributeForm($nvc);
$nvc->refreshCache();
// I don't know how cloudCount works
// I'm sure you can figure it out though
// Its optional i think(defaults to 10)
// $args['cloudCount']


EDIT: Actually save uses a $_REQUEST call so we'll h_might_ have to baby sit that. See changes above.

The tags block uses a database table to keep track of tags so I don't think you can just go through setAttribute without also adding to that table. Which is why it's probably less of a headache to just go through the controllers save method.

I didn't test this at all.