Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » TagField module

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 560 Views
  • Mackodlak
    Avatar
    Community Member
    95 Posts

    TagField module Link to this post

    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

  • Mackodlak
    Avatar
    Community Member
    95 Posts

    Re: TagField module Link to this post

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

  • UncleCheese
    Avatar
    4085 Posts

    Re: TagField module Link to this post

    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

  • Mackodlak
    Avatar
    Community Member
    95 Posts

    Re: TagField module Link to this post

    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.

  • Mackodlak
    Avatar
    Community Member
    95 Posts

    Re: TagField module Link to this post

    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?

    560 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.