How can I create a new module type? Topic is solved
-
- Joomla! Enthusiast
- Posts: 181
- Joined: Wed Oct 01, 2014 10:25 am
How can I create a new module type?
I would like to create a module type (not a position) that pre-loads fixed uneditable content (like the Joomla Footer).
There would be an option to select it alongside the other module types ("Articles - Archived", "Articles - Categories", etc) with "My Module Position" as a title with a description under the module type name, in the same way that the 'Footer' module type says "This module shows the Joomla copyright information".
When the module type is selected, the content editor should not be available, only the Menu Assignment, Advanced and Permissions tabs, again as with the Joomla footer module type.
I tried an override of the Footer module type but it doesn't do what I want (unlike an article or category override which appears as a new type). The override still says "Footer" and "This module shows the Joomla copyright information" which, if you want to keep that module type as well, is no good.
Thanks in advance.
There would be an option to select it alongside the other module types ("Articles - Archived", "Articles - Categories", etc) with "My Module Position" as a title with a description under the module type name, in the same way that the 'Footer' module type says "This module shows the Joomla copyright information".
When the module type is selected, the content editor should not be available, only the Menu Assignment, Advanced and Permissions tabs, again as with the Joomla footer module type.
I tried an override of the Footer module type but it doesn't do what I want (unlike an article or category override which appears as a new type). The override still says "Footer" and "This module shows the Joomla copyright information" which, if you want to keep that module type as well, is no good.
Thanks in advance.
Last edited by toivo on Fri Nov 13, 2020 1:18 pm, edited 1 time in total.
Reason: mod note: moved from 3.x Coding
Reason: mod note: moved from 3.x Coding
-
- Joomla! Ace
- Posts: 1840
- Joined: Fri Jul 05, 2013 10:35 am
- Location: Parts Unknown
- AMurray
- Joomla! Champion
- Posts: 6472
- Joined: Sat Feb 13, 2010 7:35 am
- Location: Australia
Re: How can I create a new module type?
@GillianBPP is your question about Joomla 3 or Joomla 4? You posted in the J4 Related Forum. Are you using Joomla 4 (Beta 4 or 5?) If not, why posting in the J4 related forum? J4 is not production ready, so shouldn't be used on live sites.
Note the instructions given by @SharkyKZ are for J3.
Note the instructions given by @SharkyKZ are for J3.
Regards,
--------------------------------------------------------------
A Murray
Help you I can, yes!. Post your question, you should. Keep it on topic you must!
Use the Forc....Forum Post Assistant my young Padawan!
--------------------------------------------------------------
A Murray
Help you I can, yes!. Post your question, you should. Keep it on topic you must!
Use the Forc....Forum Post Assistant my young Padawan!
- sozzled
- Joomla! Exemplar
- Posts: 9999
- Joined: Sun Jul 05, 2009 3:30 am
- Location: Canberra, Australia
Re: How can I create a new module type?
@AMurray and @GillianBPP: for most intents and purposes it doesn't matter if this question relates to J! 3 or J! 4; the principle is the same and the information given by @SharkyKZ is reliable and the best available at this time. There may be some additional precautions involved in developing an extension that works with PHP 7.3+; PHP 7.3 is needed for J! 4. If people want to know what these additional matters are they can start by reading https://docs.joomla.org/Potential_backw ... n_Joomla_4.
The main points to remember when asking questions about J! 4 on the forum are (a) there's no support for J! 4 and the discussions we're having are largely based on educated guesswork, and (b) because J! 4 is still unstable (and there are no specific J! 4-related forums like there are for previous versions) our discussions are broad-ranging, general and non-specific. At this time, while J! is still evolving, there are probably better places on the internet when specific developer questions can be addressed (e.g. GitHub and Joomla StackExchange). Otherwise you'll just have to dive in the deep end and discover the solution yourself.

The main points to remember when asking questions about J! 4 on the forum are (a) there's no support for J! 4 and the discussions we're having are largely based on educated guesswork, and (b) because J! 4 is still unstable (and there are no specific J! 4-related forums like there are for previous versions) our discussions are broad-ranging, general and non-specific. At this time, while J! is still evolving, there are probably better places on the internet when specific developer questions can be addressed (e.g. GitHub and Joomla StackExchange). Otherwise you'll just have to dive in the deep end and discover the solution yourself.

What's wrong with using the built-in Custom module? Unless you want to do some display information obtainable only from a specialised DB query, the built-in Custom module may be good enough?GillianBPP wrote: ↑Tue Sep 22, 2020 5:38 pmI would like to create a module ... that pre-loads fixed uneditable content (like the Joomla Footer).

https://www.kuneze.com/blog
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”

-
- Joomla! Enthusiast
- Posts: 181
- Joined: Wed Oct 01, 2014 10:25 am
Re: How can I create a new module type?
Sorry for the delay replying, I didn't get any notifications of answers.
This is J4 and I am developing my own template so that when J4 goes live I will be ready to convert my clients' existing templates from J3 to J4. I know how to create modules. I would like to create a module 'type' that shows up here:

Just like the Joomla Footer module that has pre-loaded content.
Sorry I didn't make myself clear enough to begin with.
You do not have the required permissions to view the files attached to this post.
- ceford
- Joomla! Enthusiast
- Posts: 165
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: How can I create a new module type?
You could look at this tutorial:
https://docs.joomla.org/J4_Module_example_-_Mydownmsg
And the related tutorial mentioned at the start. And there is:
https://docs.joomla.org/J4.x:Creating_a_Simple_Module
https://docs.joomla.org/J4_Module_example_-_Mydownmsg
And the related tutorial mentioned at the start. And there is:
https://docs.joomla.org/J4.x:Creating_a_Simple_Module
-
- Joomla! Enthusiast
- Posts: 181
- Joined: Wed Oct 01, 2014 10:25 am
Re: How can I create a new module type?
Thank you. I'll have a closer look at the first link you provided later.ceford wrote: ↑Fri Nov 13, 2020 2:19 pmYou could look at this tutorial:
https://docs.joomla.org/J4_Module_example_-_Mydownmsg
And the related tutorial mentioned at the start. And there is:
https://docs.joomla.org/J4.x:Creating_a_Simple_Module
As for the 'creating a simple module' one, as I said before, I'm quite happy creating modules; it's a module type to be selected from the control panel that I'm after.
- ceford
- Joomla! Enthusiast
- Posts: 165
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: How can I create a new module type?
I just installed my example module and found it in the list of available modules in the Select a Module Type list (Site). It seems that simple!
-
- Joomla! Enthusiast
- Posts: 181
- Joined: Wed Oct 01, 2014 10:25 am
- ceford
- Joomla! Enthusiast
- Posts: 165
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: How can I create a new module type?
Could you clarify what you mean by NEW and TYPE. I assume NEW means a module that does something that none of the existing modules does. You have to create and install your new module for that. TYPE? Do you mean Site or Administrator? In the list of installed modules, the Filter Options provides a - Select Type - but the types (I think) are just the titles of the modules seen in the New list, and restricted only to those currently installed. Does that Help?
-
- Joomla! Enthusiast
- Posts: 181
- Joined: Wed Oct 01, 2014 10:25 am
Re: How can I create a new module type?
Please see the screenshot I added at the top of this issue.
You will see that there are several module Types (not all of them are shown in the screenshot) starting with 'Articles - Archived', 'Articles - Categories'... 'Custom'... 'Footer'... and so on for the front-end templates (not just Cassiopeia, but any front-end template that is installed).
I want to create a new one of those 'types' that will appear in this list of module types so that my clients - who do not know how to code - can select a module type that I have created for them that will be prefilled with certain elements from the database along with custom css.
Is that any clearer?
- brian
- Joomla! Master
- Posts: 11992
- Joined: Fri Aug 12, 2005 7:19 am
- Location: Leeds, UK
- Contact:
Re: How can I create a new module type?
That is exactly what @ceford has been telling you how to do
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
- ceford
- Joomla! Enthusiast
- Posts: 165
- Joined: Mon Feb 24, 2014 10:38 pm
- Location: Edinburgh, Scotland
- Contact:
Re: How can I create a new module type?
Stage 1: Create a module with a distinctive name. Compress to make a zip file. Did you do that?GillianBPP wrote: ↑Fri Nov 20, 2020 5:09 pmI want to create a new one of those 'types' that will appear in this list of module types so that my clients - who do not know how to code - can select a module type that I have created for them that will be prefilled with certain elements from the database along with custom css.
Stage 2: Install the module via System / Install / Extensions / Upload package file. Did you do that? Did you get a confirmation message?
Stage 3: Go to Home Dashboard / Modules / New. Your module should be in the list. If not, there must be something wrong with the module coding. Did you specify Site or Administrator?
Come back if this simply does not work. Who knows, there may be something about your module that we need to know about.
-
- Joomla! Hero
- Posts: 2906
- Joined: Sun May 04, 2008 12:37 pm
Re: How can I create a new module type?
if you refer to "type" in the column of the module manager, that is by name afaik.
someone correct me if I am wrong.. but this is by experience of building several custom modules...
it is the name of a module folder that is "mod_article_whatever" shows in your manager in column type as
"article whatever"
unless you specify any in your MOD_ARTICLE_WHATEVER text string in your
xx-XX.mod_articles_whatever.sys.ini file as
MOD_ARTICLES_WHATEVER="Articles - Whatever"
then it will show with the "-" or in any other text you like.
you cannot change all after install since extensions get registered in the db as such.
But actually there is no real type as we know it from plugins. It is just a name as you fit right.
someone correct me if I am wrong.. but this is by experience of building several custom modules...
it is the name of a module folder that is "mod_article_whatever" shows in your manager in column type as
"article whatever"
unless you specify any in your MOD_ARTICLE_WHATEVER text string in your
xx-XX.mod_articles_whatever.sys.ini file as
MOD_ARTICLES_WHATEVER="Articles - Whatever"
then it will show with the "-" or in any other text you like.
you cannot change all after install since extensions get registered in the db as such.
But actually there is no real type as we know it from plugins. It is just a name as you fit right.
-
- Joomla! Enthusiast
- Posts: 181
- Joined: Wed Oct 01, 2014 10:25 am
Re: How can I create a new module type?
Hello again. I got there in the end. Thank you and apologies for my temporary mental blindness.
I think it would be a good idea to add this page link - https://docs.joomla.org/Standard_form_field_types - alongside the instructions for the manifest file.
Can you explain why the main mod_mymodule.php has no closing `?>` at the end of the file?
Thank you
I think it would be a good idea to add this page link - https://docs.joomla.org/Standard_form_field_types - alongside the instructions for the manifest file.
Can you explain why the main mod_mymodule.php has no closing `?>` at the end of the file?
Thank you
- toivo
- Joomla! Master
- Posts: 13265
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Zagreb, Croatia
Re: How can I create a new module type?
The PHP closing tag is optional. In fact, it is better to omit it.GillianBPP wrote: ↑Thu Dec 10, 2020 11:12 amCan you explain why the main mod_mymodule.php has no closing `?>` at the end of the file?
Ref. PHP: PHP tags - Manual
Toivo Talikka, Global Moderator
-
- Joomla! Enthusiast
- Posts: 181
- Joined: Wed Oct 01, 2014 10:25 am