Component vs Module development [SOLVED]

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
Adun
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Nov 28, 2013 9:26 pm

Component vs Module development [SOLVED]

Post by Adun » Sat Mar 29, 2014 9:22 am

Hello everyone,

I've found an awesome tutorial to develop a Module "quick contact". It's a simple module for building a contact form and for managing some associated settings. Regarding my needs, I'm just wondering if I have to develop this functionality as a component rather than a module.

Actually, I have a single page where I want to display the contact form as the main content (like an article) and not as secondary content (like a module panel). I have no other information to display on this specific page.

What do you think? Do I need to develop a component or can I develop just a module? I think that it's not possible to link an item menu with a simple module...

On the other hand, is it possible to develop a very simple component without model? I don't need to manage data from the database so I will have controller and view but not model. It's not really a MVC approach.

What do you think?

Thank you very much
Last edited by Adun on Sat Mar 29, 2014 3:42 pm, edited 1 time in total.

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Component vs Module development

Post by sovainfo » Sat Mar 29, 2014 10:59 am

It is very easy to turn a module into a component. Just rename mod_ to com_ and move it from modules to components. Because you didn't convert it to the expected MVC you'll miss out on several things. Unless you used MVC in your module instead of the common practise. Probably still need to make some changes in that case.

For pubishing a module in the space used for components you can use loadmodule or loadposition in an article and create a menu item for that article.
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

Adun
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Nov 28, 2013 9:26 pm

Re: Component vs Module development

Post by Adun » Sat Mar 29, 2014 11:12 am

Thank you very much sovainfo!

Following your answer, I understand that "the cleanest" and the easiest way to manage this issue is to develop the module and to use loadmodule inside the article (as described in the link below):
http://docs.joomla.org/How_do_you_put_a ... article%3F

goedda
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Sat Aug 06, 2011 3:40 am

Re: Component vs Module development

Post by goedda » Sat Mar 29, 2014 11:23 am

It depends more on what exactly you are trying to achieve. I will try to elaborate with my limited knowledge of Joomla! extensions.

A form in Joomla! is always sent to the 'index.php' file and from there to the controller of the component it was sent from. It does not really matter what 'action' attribute you define. Thus, to process a form and possibly react in some manner to it (reply, db storage, redirection etc.), you will need a component (or some sort of controller).

It is possible that you use an existing Joomla! component (or controller) like 'com_users' or 'com_contact' to process your form. If you could provide a link of the tutorial you used to create the module, I could check that. If that is the case, you usually have hidden fields in the form with the name 'option' and some other $_POST data for the component (or controller) to use.

In short: A module is more a shortcut to a component or to display data of a component. It is not so much an independent Joomla! extensions.
We come in peace, always!
http://www.quadrifolia.ch

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Component vs Module development

Post by sovainfo » Sat Mar 29, 2014 11:49 am

When you only want the module in the component position, yes.

As mentioned by @goedda a module doesn't have the capability to process its own actions, unless they are client (browser) related. You rely on components to process them, the server part. See the login module as example.

Think that the introduction of AJAX will bring the two closer. Maybe the distinction between the two will even disappear.

Disagree on the 'In short' of @goedda, but if it helps you to understand, fine with me.
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

Adun
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Nov 28, 2013 9:26 pm

Re: Component vs Module development

Post by Adun » Sat Mar 29, 2014 1:11 pm

Thanks for your answers.

You will find below the link for the tutorial:
[youtube].com/watch?v=npx8QR-mn6Y&list=UUgzk4AMvuFhk-w0kIcoXSLw

It's just a module sending a mail from a contact form. No interaction with database.
Sending the mail is the only action required on the server side.

I think that the best option will be to develop the module (like in the tutorial) and to use loadmodule in an article.
What do you think?
Last edited by Adun on Sat Mar 29, 2014 1:22 pm, edited 1 time in total.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30936
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Component vs Module development

Post by Per Yngve Berg » Sat Mar 29, 2014 1:20 pm


Adun
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Nov 28, 2013 9:26 pm

Re: Component vs Module development

Post by Adun » Sat Mar 29, 2014 1:26 pm

Hello Per Yngve Berg,

I know that there are a lot of extensions already developed but I really want to improve my knowledge as developer with this CMS. So I try to develop by myself some basic functionalities :)

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30936
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Component vs Module development

Post by Per Yngve Berg » Sat Mar 29, 2014 1:51 pm

In that case, start with a Component. You can add a module later to display the form.

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Component vs Module development

Post by sovainfo » Sat Mar 29, 2014 3:30 pm

Sending the mail would be something that requires the server to do something for you. Unless that functionality is available somewhere you would have to create it yourself.
So, turn the module into a component. Create the task to sendmail and have the form in your view call that.
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

Adun
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Nov 28, 2013 9:26 pm

Re: Component vs Module development

Post by Adun » Sat Mar 29, 2014 3:41 pm

Ok noted,

I will develop a component.

Thanks sovainfo!


Locked

Return to “Joomla! 3.x Coding”