Easiest way to select multiple categories?

edited March 2016 in Modules
Is there an easy, built-in way (using $foreign_keys maybe) to allow users to assign multiple categories using FUEL's category tool?

I've begun something already. If there's no native support for it, do you recommend using a multi form and populating it with all categories, then (during processing), just inserting a record for each category? Or maybe serializing the category_id field (this is for news articles, by the way) so that multiple categories can be in the category_id field of the database?

Thanks!

Comments

  • edited 4:01PM
    I'd recommend a has_many with fuel_tags instead:
    public $has_many = array( 'tags' => array(FUEL_FOLDER => 'fuel_tags_model') );
  • edited 4:01PM
    But instead of tags and fuel_tags_model, I'd use categories and fuel_categories_model, right?
  • edited 4:01PM
    I'd recommend using tags because the tags model is setup to handle belongs_to_many relationships so you can automatically get all the records for that tag with:

    foreach($tag->my_relationship_keys as $my_relationship_key) :
    print_r($my_relationship_key->values());
    endforeach;
    Tags are meant for many-to-many relationships which sounds like what your are needing here. Categories are for single foreign key relationships (and can be hierarchical): http://docs.getfuelcms.com/general/tags-categories
Sign In or Register to comment.