• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forum prototype - Constructive criticism requested.

I'm also starting to think the MVC approach may not be the way to go, as there's no clear cut between what goes where... Maybe there's a reason 99% of forums are done using procedural?

Also, as for making it so that it works with CI only (in the mean time) is asking for trouble, is it not? As soon as you start building it on top of CI, using CI features, you make it harder to port to another framework.
This is one benefit of doing it all in object... It would effectivly become a library which can be dropped in, as pretty much everything else is framework specific

As for where you should put a method like get_thread... I would put that in the thread model.
I came accross a similar dilema a few days ago, I had the following database table
Getting a single user obviously (to me atleast) went into the user model, but I was unsure where to put the get_users (for a specific account) method.
In the end, I put it in the account model, and done a join there, purely for the reason it seems more natural when writing it

Not sure if anything I just said really helps you, but I hope so

Yes, that really does help. Thanks a lot for your comments. I know I over-think things a lot, but it's nice to know that it's not just me who sees problems like this in seemingly simple decisions.

The only reason I wanted to create the forum to be CI specific (to start anyway), is simply because CodeIgniter is a great framework, and doesn't have a forum tailored to take advantage of that framework. Also, as this is for a client, I need to get it finished ASAP, and I think the only way to do that, is to depend on CodeIgniter being the backbone. Also, there are a lot of forums out there, and I don't want to contend with them just yet, I just want to provide my fellow CodeIgniters with a fairly decent, simple forum. I think you're right though, forums are generally written in a procedural style. I was thinking of going with a model along these lines, all one model:

class Forums_model extends Model
    function Forums_model() { parent::Model(); }
    function get_forum($id) {} # Returns the specified forum as a forum object.
    function add_forum($forum_object) {} # Adds a forum.
    function update_forum($forum_object) {} # Updates a forum.
    function delete_forum($id) {} # Deletes the specified forum.
    function get_child_forums($forum_id) {} # Returns an array containing any child forums.
    function get_child_threads($forum_id, $page_num) {} # Returns an array containing the child threads within the given page.
    function add_thread($forum_id, $user_id, $title) {} # Adds a new thread
    function delete_thread($thread_id) {} # Deletes a thread.
    function update_thread($thread_id, $forum_id, $title) {} # Updates a thread.
    function get_thread($thread_id, $page_num) {} # Returns an array of posts. Not sure if I actually need to implement this.
    function add_post($post_object) {} # Adds a post.
    function update_post($post_object) {} # Updates a post.
    function get_post($post_id) {} # Returns the post with the specified ID.

I think it's a little bit inconsistent, as there's no thread object, and probably needs a little tweaking, but by using objects, I'm hoping to be able to easily implement changes (adding extra fields), without ending up with functions that take lots of arguments, in a seemingly random order. At least with objects and associative arrays, it allows for expansion much more easily IMHO. Also, there are a lot more methods to be added, but I just want to stick to the basics for now.

As always, comments and criticism welcome.

Thanks again!

Holy underpants! [url="http://ellislab.com/forums/viewreply/573474"]bargainph has found a CodeIgniter based forum[/url] in the [url="http://codeigniter.com/wiki/MyForum/"]wiki[/url]. I had no idea... I'm going to check it out tomorrow.

I thought I'd update this thread with my findings. "My Forum" is a very simple forum, that's lacking a lot of features and functionality. It was coded based on chapter 5 of the "Practical PHP and MySQL" book. I'm quite sure it can be built upon. It's nicely made, and at a lower level proves that you can indeed create a forum built upon the MVC pattern.

Taken from the install guide:
Quote:MyForum is a free simple forum-type application based on the PHP framework CodeIgniter v1.7.1. Please note that this software was a learning exercise for me, and was not intended to be a full-featured, glitzy, must-have app. It has not been fully tested on a lot of systems and most likely contains bugs. If it works out of the box for you, great; if not sorry i cannot help.

I'm still very grateful for this example, however. I've also decided that I will create my forum with CodeIgniter, then anyone is free to write their own abstraction layers if they wish. There are already lots of forums out there - some easier to integrate than others - which is why I would like to stick with CodeIgniter, as it would be impossible to design a forum that can be easily integrated into just about any Web site.

Big thanks to everyone who helped, or just wanted to help - particularly Dam1an - without whom I'd still be as confused as a cow on Astroturf.

First of all, your prvious post to the wiki isn't a link, it just point to http:///
Secondly, glad I was of some help Smile

Having seen how myForum is implemented, you come up with a final architecture, or is that still in progress?

[quote author="Dam1an" date="1241555466"]First of all, your prvious post to the wiki isn't a link, it just point to http://[/quote]


[quote author="Dam1an" date="1241555466"]Having seen how myForum is implemented, you come up with a final architecture, or is that still in progress?[/quote]

Uhm... No. But I have a sense of direction now, so that's something! Big Grin

I think I have the structure sussed to the point that I can expand easily without having to do any more rewrites, and that's good enough for me.

Cool... maybe you could intergrate this project with your "port wordpress to CI" project Tongue
Hmmm a forum blogging platform... that could be interesting

Anyway, be sure to keep us posted about the progress of your forum Smile

Possibly of interest on your CI-based forum quest: somebody has taken MyForum a step further, or at least put some effort into the css styling: see subcultura.es/v2/foro perhaps the person would be willing to share their code enhancements; but if not at least it's another operational CI forum to review.

[eluser]Thorpe Obazee[/eluser]
[quote author="TheFuzzy0ne" date="1241372486"] I just want to provide my fellow CodeIgniters with a fairly decent, simple forum. [/quote]

That being said, I'd like to be a tester if ever that forum is released(will it be released?).

I'm hoping so, although I can't say with any certainty just yet. My aim is to just get the forum working, and then I need to work on making it a standalone app, and making it easy to integrate into an existing set up. Sound simple enough? Well, it not! Tongue

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.