I've been reading as much literature as I can, but it's not clicking.

Would I be right in assuming Modules and Plugins are just the same thing?

Honestly, I don't know what a Component is. Something that modifies the site's or module's config rules?

And I think Ctools is it's self a Module, that allows you to create other Modules and Plugins from it...

If it helps, I'd like to understand these more to complete a task I've been given. Fundamentally, I just need to write a simple JS script that detects the URL and outputs some HTML on the page. On previous CMSs I've used I would write this as either a standalone .js file or place it within an existing .js file and then use the CMSs template variables or template files to make sure it only appearred on pages I want it to appear on.

With this Drupul project, my instructions where to 'Create a component with this JS. Then place this JS into an existing module that triggers at the right time'.

My first step was to Google 'How to create Drupal Component' but I only came up with How to Create a Module or Theme stuff.

Long story short, I first need to understand what these things are before I can look into actually creating one.

Many thanks in advance for any answers.

Comments

Jaypan’s picture

Modules and plugins are not the same thing.

Modules provide functionality for a system. You can download modules from Drupal.org.

Plugins are not part of Drupal 7. In Drupal 8 they are a piece of functionality that can be re-used in different classes. A plugin will be part of a module, and a module may implement multiple plugins.

Ctools is a module that provides various functionality for developers who wish to use it. Think of it as a toolkit of functionality that you can use to save time in developing some regularly used functionality.

Anonymous’s picture

Cool thanks. What about components?

Jaypan’s picture

It's not really a term used a lot in Drupal. I'd as the person who gave you the task whether they meant component in a generic way, or something specific to Drupal.

John Pitcairn’s picture

Is this an exercise or a real project you've been given?

In Drupal you generally try to avoid modifying (hacking) existing core, module or theme code. When that gets updated it will wipe out your modifications.

If you have custom js you need to inject, you would either do it in your subtheme of an existing theme or you would make a simple custom module.

See Managing javascript in Drupal 7.

Anonymous’s picture

Thanks for the reply.

This is a real project. After digging around a bit more I understand my .js file is to be added to a custom-made module that deals with all the site's product pages.

Jaypan’s picture

Either a module, or the theme.

The way to decide is:

1) If the JS functionality is something that is theme specific - ie you would not need that JS if you went for a different theme (design) on your site, then you put the JS in the theme. If the functionality is something that should persist even if you put in a different design (for example, an ajax poll that looks for new messages), then you put the JS in a module.