Welcome Guest, Not a member yet? Register   Sign In
Libraries or HMVC
#1

[eluser]alphasynaptic[/eluser]
So if I'm building an app with CI + Ajax where each page gets content from several different pages and places it onto the main page, should I use libraries despite the fact that I won't be reusing the functions or should I use an HMVC approach? I wish there was a simple way to load controllers from controllers but doesn't look like there is. I believe this isn't a problem of me not understanding the structure or capabilities of MVC but rather the fact that Ajax and MVC do not get along, I could be wrong though. Any help would be appreciated. Thanks in advance.
#2

[eluser]Colin Williams[/eluser]
Quote:but rather the fact that Ajax and MVC do not get along

Worst, most inaccurate, sweeping generalization I've heard on this forum thus far!

Quote:I could be wrong though.

Whew! Ok. That's better. It's hard for us to make a good recommendation—and believe me, we want to—with such a vague background of your project.

Quote:where each page gets content from several different pages and places it onto the main page

Well, is a page a unit that would be stored in a database? In that case, you just need a single page controller that queries whatever pages you want to display.

If a page is more like a widget, each coming from one of a group of widget controllers, then I think HMVC could be a good architecture for you. Although, using Libraries could work just as well. It just depends on how you want to build it.

I would have a widget controller that, among other things, communicates with a widget model to get the widget instructions, save widgets, etc. The widget controller is the widget hub. Then I would have a widget library that serves as the Widget API, and then a separate library for each widget. The Widget API library, upon loading, would load all *_widget.php libraries in the constructor. So, the widget controller would only ever speak to the Widget API, passing along instructions from the database (via the model). I hope you see where I'm going with this...
#3

[eluser]alphasynaptic[/eluser]
Quote:
Quote:but rather the fact that Ajax and MVC do not get along
Worst, most inaccurate, sweeping generalization I’ve heard on this forum thus far!
Nice way to give good advice and still be an @$$hole about it.
#4

[eluser]Colin Williams[/eluser]
Aww.. come on man. I liked your original response better.

Quote:Colin shut up and gtfo of my thread. I've seen you hijack numerous threads and not once have you been remotely helpful to the users other than being an arrogant naysayer.

Especially the "not once have you been remotely helpful to the users" part. To be fair, you probably also saw my abbreviated original response, which, for sure, wasn't helpful at all. I really am here to provide help. Please take my lighthearted, smart-ass quips with a grain of salt. 99% of the time I'm just being facetious, as I was here.

I knew well what you meant by "I believe this isn’t a problem of me not understanding the structure or capabilities of MVC but rather the fact that Ajax and MVC do not get along," and I purposefully took it out of context to have a little fun.
#5

[eluser]Yash[/eluser]
Stop all this here.

Please close this thread
#6

[eluser]Derek Jones[/eluser]
Civil, fellas...
#7

[eluser]Colin Williams[/eluser]
My apologies, all. HMVC vs. Libraries is an important topic to discuss. I think a lot of new-comers to MVC and CodeIgniter run into it at some point early on. Care to shed any light on which, if any, way you're currently leaning, alphasynaptic?
#8

[eluser]johnwbaxter[/eluser]
Perhaps you should add something in your signature that explains your "sense of humour" so new posters don't take what you say the wrong way. Just a thought...
#9

[eluser]alphasynaptic[/eluser]
I apologize then. I merely took it as arrogance and not humor. On further contemplation, I was considering maybe loading the content boxes initially with Ajax since they will be loaded by Ajax anyway once the user attempts interaction. Any comments?
#10

[eluser]Colin Williams[/eluser]
Quote:I was considering maybe loading the content boxes initially with Ajax...

In that case, the standard MVC controller structure will work fine, because each little box will be a call to a Controller (at least, that's one way to do it.) Although you might want to consider what happens if the user does not have JavaScript. Whether or not to cater to a non-JavaScript crowd is a decision that should be made before you dive into code.




Theme © iAndrew 2016 - Forum software by © MyBB