How can I create a new module type? Topic is solved

Be informed that this forum is not an official support forum for Joomla! 4.0. Any issues regarding Joomla! 4.0 must be reported at https://issues.joomla.org/.

Joomla 4.0 is still in Beta stage. This forum should be used for sharing information about Joomla! 4.0.
Post Reply
GillianBPP
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 181
Joined: Wed Oct 01, 2014 10:25 am

How can I create a new module type?

Post by GillianBPP » Tue Sep 22, 2020 5:38 pm

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.
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

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1840
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: How can I create a new module type?

Post by SharkyKZ » Tue Sep 22, 2020 6:49 pm


User avatar
AMurray
Joomla! Champion
Joomla! Champion
Posts: 6466
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: How can I create a new module type?

Post by AMurray » Tue Sep 22, 2020 9:19 pm

@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.
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!

User avatar
sozzled
Joomla! Exemplar
Joomla! Exemplar
Posts: 9999
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How can I create a new module type?

Post by sozzled » Tue Sep 22, 2020 9:47 pm

@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. ;)

GillianBPP wrote:
Tue Sep 22, 2020 5:38 pm
I would like to create a module ... that pre-loads fixed uneditable content (like the Joomla Footer).
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? ???
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?” :)

GillianBPP
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 181
Joined: Wed Oct 01, 2014 10:25 am

Re: How can I create a new module type?

Post by GillianBPP » Fri Nov 13, 2020 12:29 pm

AMurray wrote:
Tue Sep 22, 2020 9:19 pm
@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.
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:

Image

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.

User avatar
ceford
Joomla! Enthusiast
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?

Post by ceford » Fri Nov 13, 2020 2:19 pm

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

GillianBPP
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 181
Joined: Wed Oct 01, 2014 10:25 am

Re: How can I create a new module type?

Post by GillianBPP » Fri Nov 13, 2020 3:07 pm

ceford wrote:
Fri Nov 13, 2020 2:19 pm
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
Thank you. I'll have a closer look at the first link you provided later.

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.

User avatar
ceford
Joomla! Enthusiast
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?

Post by ceford » Fri Nov 13, 2020 4:56 pm

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!

GillianBPP
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 181
Joined: Wed Oct 01, 2014 10:25 am

Re: How can I create a new module type?

Post by GillianBPP » Fri Nov 20, 2020 10:55 am

ceford wrote:
Fri Nov 13, 2020 4:56 pm
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!
Yes it is, if you want to select from the existing list of module types. I want to add a NEW module TYPE.

User avatar
ceford
Joomla! Enthusiast
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?

Post by ceford » Fri Nov 20, 2020 1:41 pm

GillianBPP wrote:
Fri Nov 20, 2020 10:55 am
I want to add 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?

GillianBPP
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 181
Joined: Wed Oct 01, 2014 10:25 am

Re: How can I create a new module type?

Post by GillianBPP » Fri Nov 20, 2020 5:09 pm

ceford wrote:
Fri Nov 20, 2020 1:41 pm


Could you clarify what you mean by NEW and 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?

User avatar
brian
Joomla! Master
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?

Post by brian » Fri Nov 20, 2020 6:16 pm

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/

User avatar
ceford
Joomla! Enthusiast
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?

Post by ceford » Fri Nov 20, 2020 6:55 pm

GillianBPP wrote:
Fri Nov 20, 2020 5:09 pm
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.
Stage 1: Create a module with a distinctive name. Compress to make a zip file. Did you do that?

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.

waarnemer
Joomla! Hero
Joomla! Hero
Posts: 2906
Joined: Sun May 04, 2008 12:37 pm

Re: How can I create a new module type?

Post by waarnemer » Fri Nov 20, 2020 7:50 pm

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.

GillianBPP
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 181
Joined: Wed Oct 01, 2014 10:25 am

Re: How can I create a new module type?

Post by GillianBPP » Thu Dec 10, 2020 11:12 am

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

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13261
Joined: Thu Feb 15, 2007 5:48 am
Location: Zagreb, Croatia

Re: How can I create a new module type?

Post by toivo » Thu Dec 10, 2020 12:38 pm

GillianBPP wrote:
Thu Dec 10, 2020 11:12 am
Can you explain why the main mod_mymodule.php has no closing `?>` at the end of the file?
The PHP closing tag is optional. In fact, it is better to omit it.

Ref. PHP: PHP tags - Manual
Toivo Talikka, Global Moderator

GillianBPP
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 181
Joined: Wed Oct 01, 2014 10:25 am

Re: How can I create a new module type?

Post by GillianBPP » Thu Dec 10, 2020 3:20 pm

toivo wrote:
Thu Dec 10, 2020 12:38 pm
The PHP closing tag is optional. In fact, it is better to omit it.
Thank you.


Post Reply

Return to “Joomla! 4 Related”