Module or widget?

Hello folks,

I have a website with a book reviews feature. So, the idea is that people post reviews about books that they like. Other users can then (obviously) read the reviews, but they can also post comments about the review - at the bottom of the page. This is a feature that you’ve probably seen a million times before on sites like Amazon or LinkedIn. It’s basically just a standard comments tree with a little textarea at the top and a button to submit a comment. For what it’s worth, I’ve already built this ‘book club’ in Codeigniter, but I’m hoping to switch everything over to Yii. It’s at insiderclub.org.

Anyway, I’m wondering if anyone can tell me what is the best way to handle a feature like this? I’m talking specifically about the comments tree.

I’m not looking for anyone to spell out the code for me, but if somebody could just give me some general advice then it would be amazing. In a nutshell, I can’t figure out whether I should use a module for my comments tree (can you call modules from inside normal view files?), OR should I use a widget?

Any help with this would be appreciated. Thank you so much!

David

PS - By the way, one of the things that ruined Codeigniter for me was that nobody from the community seemed to be able to figure out when to use a widget, a helper, a module, a heavily PHPified view or a thing called a view callback. It’s all a bit confused over there. I’m keeping my fingers crossed, hoping that Yii2 will have a bit more clarity when it comes to how to structure web apps.

Since this is going to be more involved than what a Widget can do, I recommend that you go the module route.

Perhaps you can use one of the existing commenting modules - at least as a starting point?

YiiGist - Comment - Yii2

That’s amazing. I never even knew about that site. Thanks!

To answer your other question:

Yes, you can use a module in your views, and everywhere, actually.

That’s amazing. I was hoping for that.

Listen dude, I’ve just posted a thread asking if somebody would allow me to hire them to ask some Yii related questions via Skype for an hour or two. I had you in mind when I posted the thing. Please do check that thread out and if you’re up for it, then please do let me know. If I could just have an hour or two discussing Yii with you, then it would surely be one of the highlights of the week. Cheers!