Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

TagField module


Reply


5 Posts   595 Views

Avatar
Mackodlak

Community Member, 95 Posts

13 June 2011 at 9:00pm

Hello,
I am interested in using this module on some custom things i programmed like Link Of The Day (LOTD extends DataObject in LOTD.php) so I would like to know how to add tags and search options for that custom class, in this case, how to use TagField module to add tags to it?
I made a form for frontend submitting and editing of LOTDs on LOTDPage.php (LOTDPage extends Page) and would like to add some tags to it for easier search
Also, is som1 knows how to add custom DataObject to built-in search I would appreciate it.

Ty all

Avatar
Mackodlak

Community Member, 95 Posts

15 June 2011 at 11:24pm

Added tags to my DataObject, they are put to DB, how to use them?
What to put in template for tags to be usefull?

Avatar
UncleCheese

Forum Moderator, 4094 Posts

16 June 2011 at 8:40am

The TagField works with a many_many relationship.

Tag.php

class Tag extends DataObject {
static $db = array (
'Title' => 'Varchar'
);

static $belongs_many_many = array (
'SomeObjects' => 'SomeObject'
);
}

YourDataObject.php

class YourDataObject extends DataObject {
static $many_many = array (
'Tags' => 'Tag'
);

public function getCMSFields() {
return new FieldSet (
new TagField('Tags')
);
}
}

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Mackodlak

Community Member, 95 Posts

16 June 2011 at 6:17pm

Yes UncleCheese, thank you, but, after you have added tags to class, which I did, how do you use them?
If I understood correctly it should be like the tags in blogmodule... usable in a form of a link in a way that when i click on a single tag, i get all of my DataObjects with the same tag displayed.
If not atlest that I can search the DataObject by tags, no?

So can you show me the example of template in which they are used?

BTW nice that you started doing tutorials, I will look at it l8r.

Avatar
Mackodlak

Community Member, 95 Posts

20 June 2011 at 6:34pm

BUMP
Anyone knows how to make those tags usable? Or did I just figure it out wrong and they aren't usable as in blog module so each is a link you click that then list all of the others with same tag?

Are they searchable?

How to write it in template?