The MU forums have moved to WordPress.org

Database Design Question (15 posts)

  1. DeannaS
    Member
    Posted 15 years ago #

    Hi all,
    I'm currently updating the categories for blogs plugin (by Certi) and the way it was originally designed, the category for each blog is added to the blog's options tables. So, if you want to find all the blogs for a category, you have to query the main blog table, loop through that, and query each blog's options table to find out if it's in that category.

    Is there any reason NOT to create a second join table (blog_category) to track blog id and category id? Certainly, in any other project, that'd be the way I'd design it. But, I'm not familiar with all the best practices of WordpressMU. So, I wasn't sure if there was some reason he'd have set it up this way initially.

    Thanks!

  2. andrea_r
    Moderator
    Posted 15 years ago #

    I would prefer a global table for the blog category. imagine having to go thru the blog options tables for 1,000 blogs. :)

    Best practise in MU is having a global table for global functions. :D

    (IMNSHO, YMMV)

  3. DeannaS
    Member
    Posted 15 years ago #

    Thanks. That's what I was thinking, too. I'm on it. Hope to have code to share soon.

  4. MrBrian
    Member
    Posted 15 years ago #

    Good point. I use the blog categories plugin too, but I've fixed it quite a bit. Perhaps you can use my version.
    -to populate the categories, it uses a text file instead of having to create an array within the plugin.
    -Fixed the bug where it didn't even save the categories for users.
    -The backend menu where you can change your category is enhanced a bit.

    http://pastebin.com/f3a14cea4

    Let me know if you don't want to use my version and I will make the changes myself. Should be pretty easy, but i thought I would share my better version if you want to build on it.

  5. d_kc
    Member
    Posted 15 years ago #

    Thanks Mr.Brian.

    Is there anything special I should do before going from the original plugin to your modified version ?

  6. MrBrian
    Member
    Posted 15 years ago #

    Nope. Just make sure the table name for the categories is the same as the one you created with the original (can't remember if they're different).

  7. d_kc
    Member
    Posted 15 years ago #

    Looks like they are.
    Got it working though, thanks.

  8. d_kc
    Member
    Posted 15 years ago #

    btw, How do you format your text file. Seeing some weird output.

  9. MrBrian
    Member
    Posted 15 years ago #

    Each category goes on a new line. Here's my categories file for example:
    http://pastebin.com/m11d56ef

  10. boonika
    Member
    Posted 15 years ago #

  11. MrBrian
    Member
    Posted 15 years ago #

    Yup, i'm already using Deanna's. It added in the relationship table, and I love efficiency.

  12. boonika
    Member
    Posted 15 years ago #

    Just trying it out. Niceeeeeeeeeeee... And it's working:)

  13. Konstan
    Member
    Posted 15 years ago #

    Just tried on my test server and it worked very nice. I am going to use it once I design a directory-like page, and if I can add a rating system to it (like http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/), just have to figure out how to insert the blog id where needed.

  14. Konstan
    Member
    Posted 15 years ago #

    Done =)

    It was actually much easier then I thought. Installed the plugin, installed the rating system, edited one file and now each blog has a rating bar next to it (its a little too big, and its being a pain to change but I hope I can figure that out too).

    Now I am rethinking about this rating thing, and I am not sure that I want it :P

    Also, can I request right away a paginated option? For people with lots of blogs.

  15. DeannaS
    Member
    Posted 15 years ago #

    Just FYI - I posted a new version of the blog topics plugin today which includes a bug fix that prevented newly signing up users from setting their blog topic.

    No time to work on the pagination thing yet... Is there a built-in pagination function in WP or PHP? (A girl can dream, right?)

About this Topic