add module automatically on position without select position Topic is solved

General questions relating to Joomla! 4.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
sofian10
Joomla! Intern
Joomla! Intern
Posts: 97
Joined: Sat Dec 24, 2016 9:26 am

add module automatically on position without select position

Post by sofian10 » Sat May 27, 2023 4:37 pm

hi
i want to add module in a position without select any positions .
this mean :
click to add the module , setup settings and click save without chose position, then the module show on the page .

is it possible to do it ?

thanks
Last edited by imanickam on Sun May 28, 2023 3:23 am, edited 1 time in total.
Reason: Moved topic » from Joomla! 4.x Coding to General Questions/New to Joomla! 4.x

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: add module automatically on position without select position

Post by sozzled » Sat May 27, 2023 7:33 pm

Although the documentation for adding a new module in J! 4.x is not as comprehensive as documentation written for previous versions of J!, a module will not appear on a website unless it has been assigned to a position on the template. That is how J! has always worked.

So, to answer your question,
sofian10 wrote:
Sat May 27, 2023 4:37 pm
Is it possible to [add a module and display it on a website without assigning the module to a template position]?
The answer is no.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 42902
Joined: Sat Apr 05, 2008 9:58 pm

Re: add module automatically on position without select position

Post by Webdongle » Sat May 27, 2023 7:44 pm

In theory a module installation script could search the database for the Default Template. Then search for the Positions for the Template. But in practice randomly assigning the module to a vacant position would end in CHAOS
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

sofian10
Joomla! Intern
Joomla! Intern
Posts: 97
Joined: Sat Dec 24, 2016 9:26 am

Re: add module automatically on position without select position

Post by sofian10 » Sat May 27, 2023 8:03 pm

i dont mean to add the module without position .
i mean , how to add the module in this position automatically .
or
how to make the position selected by default when open the module admin form ?

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

Re: add module automatically on position without select position

Post by AMurray » Sat May 27, 2023 11:43 pm

Seems a very impractical idea to have one specific position as default. Joomla is not going to know where you want to place the module until you tell it what position you want it in.
Regards - A Murray

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

Re: add module automatically on position without select position

Post by Per Yngve Berg » Sun May 28, 2023 7:29 am

Perhaps you should tell us the reason for this strange request. Then we may have a solution for you.

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: add module automatically on position without select position

Post by sozzled » Sun May 28, 2023 7:59 am

The question is "How can you automatically select a module position by default when creating a new module in Joomla?". It's a simple question. We don't need to know the reason why. The reason is obvious: people forget to assign an module position or they're too lazy to perform one mouse-click before pressing the Save button.

Here's the solution: write a plugin to populate the position text box.

I'm not going to write this plugin (to save one mouse-click) for someone else without some added incentive. ;)

A better—and the cheapest—solution is to remember to perform one extra mouse-click (to select the module position) before you press the Save button.

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

Re: add module automatically on position without select position

Post by Per Yngve Berg » Sun May 28, 2023 8:19 am

Simplest solution: Override the form in the Administrator template and add a Default Value to the Input Element.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 42902
Joined: Sat Apr 05, 2008 9:58 pm

Re: add module automatically on position without select position

Post by Webdongle » Sun May 28, 2023 9:36 am

sozzled wrote:
Sun May 28, 2023 7:59 am
The question is "How can you automatically select a module position by default when creating a new module in Joomla?". It's a simple question. We don't need to know the reason why. ...
Yes we do because the OP often think they know how to solve their problem but don't. Hence they ask the wrong question. If they tell us what they are trying to achieve then we ca often work out how they can achieve it.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

sofian10
Joomla! Intern
Joomla! Intern
Posts: 97
Joined: Sat Dec 24, 2016 9:26 am

Re: add module automatically on position without select position

Post by sofian10 » Sun May 28, 2023 7:20 pm

here is my idea :
i added this code in a file in my videos component :

Code: Select all

<?php echo JHtml::_('content.prepare', '{loadposition playlist_module}'); ?>
this code added a custom position in my component .
the word "playlist_module" is not included in positions select menu . i must to write it all the time and cant find it when search it . so i want to add the module in easy way , because i forget this name and need to open the php file to coppy it . also i will add this module very much times on this position .
Per Yngve Berg wrote:
Sun May 28, 2023 8:19 am
Simplest solution: Override the form in the Administrator template and add a Default Value to the Input Element.
can you tell me more about this form ? where is it , what is its name ? please .

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

Re: add module automatically on position without select position

Post by Per Yngve Berg » Sun May 28, 2023 7:54 pm

It's Module Manager in the Administrator.

Can you use this: https://extensions.joomla.org/extension/allvideos/

It's a Plugin instead of a module.

sofian10
Joomla! Intern
Joomla! Intern
Posts: 97
Joined: Sat Dec 24, 2016 9:26 am

Re: add module automatically on position without select position

Post by sofian10 » Sun May 28, 2023 9:35 pm

Per Yngve Berg wrote:
Sun May 28, 2023 7:54 pm
It's Module Manager in the Administrator.

Can you use this: https://extensions.joomla.org/extension/allvideos/

It's a Plugin instead of a module.
no i will not use it , because i have a full video component works like [youtube] site .
i dont use articles on my site .

thanks

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 42902
Joined: Sat Apr 05, 2008 9:58 pm

Re: add module automatically on position without select position

Post by Webdongle » Sun May 28, 2023 9:49 pm

sofian10 wrote:
Sun May 28, 2023 7:20 pm
here is my idea :
i added this code in a file in my videos component :

Code: Select all

<?php echo JHtml::_('content.prepare', '{loadposition playlist_module}'); ?>
this code added a custom position in my component .
the word "playlist_module" is not included in positions select menu . ...
That's because that code does not add a position to the list. The position needs to be declared in the Template's templateDetails.xml file for it to be listed. https://docs.joomla.org/Declaring_module_positions
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: add module automatically on position without select position

Post by sozzled » Sun May 28, 2023 9:56 pm

OK ... so now that we understand why the OP wants this, is it possible to set things up so that any (or a specific) newly-added module uses the position playlist_module as the default (without having to key-in the value)? Yes or no and, if yes, how?

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

Re: add module automatically on position without select position

Post by Per Yngve Berg » Mon May 29, 2023 7:18 am

You will have a better solution using a Plugin rather than a Module.
https://docs.joomla.org/Supporting_plug ... _component

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1339
Joined: Tue Jun 30, 2020 12:17 pm

Re: add module automatically on position without select position

Post by Pavel-ww » Mon May 29, 2023 7:49 am

sofian10 wrote:
Sun May 28, 2023 7:20 pm
the word "playlist_module" is not included in positions select menu . i must to write it all the time and cant find it when search it . so i want to add the module in easy way , because i forget this name and need to open the php file to coppy it . also i will add this module very much times on this position .
Hi. You can add position to templateDetails.xml, following @Webdongle's advice. But this is optional. If at least one module was published in position just by writing its name, then you can find it in active positions.
1.jpg
2.jpg
And if you will add a module to this position many times, you will definitely not forget its name :D.

I think you will come to the fact that the solution to this problem in the way that you want to solve it does not make sense. Personally, I very often use my own positions and have never experienced discomfort. Joomla basic capabilities are enough to manage all these things.
You do not have the required permissions to view the files attached to this post.

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

Re: add module automatically on position without select position

Post by AMurray » Mon May 29, 2023 9:04 am

Normally you would use plugins within articles such as a "quick tag" type that might for instance embed a video player instead of having to use the actual HTML <embed> or <iframe> which are typically used to embed third party content (such as YT videos and the like).
Regards - A Murray

sofian10
Joomla! Intern
Joomla! Intern
Posts: 97
Joined: Sat Dec 24, 2016 9:26 am

Re: add module automatically on position without select position

Post by sofian10 » Mon May 29, 2023 2:57 pm

I thank you all for your cooperation and assistance.
I decided to use "Save as a copy", and here the settings will remain constant and repeated with the same options.
Once again thanks


Post Reply

Return to “General Questions/New to Joomla! 4.x”