scribbly Posted April 6, 2014 Share Posted April 6, 2014 Hi Larry: I'm happily working through your book, but not implementing it as such, more translating it into my current project. What I'm wanting to do is to have the ability for users to use #tags. I don't think it's an issue if it was just one model involved, but what I want to do is have all the models tag-able... using the book's set-up: users can tag them selves, pages can be tagged and files can be tagged -- all using the same tbl_tag. What I want to be able to do is implement a search and/or tag cloud so that selecting the one tag will return records from each table (if they are correctly tagged). If I had my database hat on I'd say you'd do something like: tbl_user_has_tags tbl_page_has_tags tbl_file_has_tags and use a view to union them all together. But I'm not sure how that works with yii... can you give me a direction to start in? Thanks, Link to comment Share on other sites More sharing options...
Larry Posted April 7, 2014 Share Posted April 7, 2014 This is an interesting one... My inclination would be to use one table. You could store ID, type, and tag ID. It'll be some work cross referencing everything one way or the other. Link to comment Share on other sites More sharing options...
scribbly Posted April 7, 2014 Author Share Posted April 7, 2014 You may have guessed that I'm just up to Views in your book, and working up to use bootstrap thumbnails... but I can't help thinking ahead and thinking about database structure. Your one table option could be achieved using a view? I've not got into yii using views, but I'm hoping that it'd be basically the same as using a table? My thoughts on a separate view is that each module_has_tags table can also be used individually when displaying the module, and the view over the whole application. With my db hat on... the view would add the module_type. I was thinking that the tags would only be added to the record when in edit mode, but I'm not sure that's reasonable or not? The other thing was how it gets implemented... I had a look at a tagging plugin and it used behaviours. I'm guessing that when viewing the result, that it's collected using a query (WHERE tag_id = this_tag_id)? Link to comment Share on other sites More sharing options...
Larry Posted April 18, 2014 Share Posted April 18, 2014 Yeah, you could use a view table here. I don't think I've ever used a view table with Yii, so I'm not sure how that would go. The tags ought to be addable when the record is added. And editable when the record is editable. Link to comment Share on other sites More sharing options...
Recommended Posts