Cannot add setAttribute() to tags
Permalink 1 user found helpful
i just trying to auto add tags, but not work, its not save
but if i use my own atribut 'is_featured', it save
how to add attribut tags automatically?
$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?
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
unfortunately I don't have to time right now to dig any deeper,
sorry,
Mike
okay mike, thanks for digging :)
Fixed
Ha haa.. that puny pop-up
do u want my cookie?
do u want my cookie?
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.
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.
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']
Viewing 15 lines of 20 lines. View entire code block.
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.
but still not work
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