Loading a module only if viewed on mobile

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
Forsh
Joomla! Explorer
Joomla! Explorer
Posts: 351
Joined: Sat Aug 20, 2005 3:05 pm
Location: 1135 N Broadway #213 Denver, CO 80203
Contact:

Loading a module only if viewed on mobile

Post by Forsh » Wed Nov 01, 2023 7:46 am

Is there a way to get a Joomla module to only display on a mobile view and another way to display only on a desktop view? I am having trouble with images looking terrible when one image is showing for both views. I would like to have two variations of one module but only one module will load depending on the view. Looking for native Joomla solution if possible or maybe a plugin. Not a new component like SP Pagebuilder, I know that can do it, just looking for my mainpage image module to have this functionality if there's any possibility of doing this.

artonweb
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 189
Joined: Mon Oct 24, 2011 5:07 am
Location: Hellas
Contact:

Re: Loading a module only if viewed on mobile

Post by artonweb » Wed Nov 01, 2023 10:05 am

Hello.
If you are designing a new website you can use the template heliχ Ultimate of JoomShaper which gives you the possibility to display modules only on specific resolutions of screens.
Image

User avatar
Cnossos
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Wed Mar 16, 2022 7:25 am
Contact:

Re: Loading a module only if viewed on mobile

Post by Cnossos » Wed Nov 01, 2023 10:15 am

To keep it very simple, you may want to assign a css class to each module, in the 'advanced' tab of the module manager. For example 'mobile-only' and 'desktop-only'. Then, in your custom css file (and depending on your own break points of course), you could have something like:

@media screen and (max-width: 959px) {
.desktop-only {
display: none;
}
}

@media screen and (min-width: 960px) {
.mobile-only {
display: none;
}
}

Something like this?

User avatar
pablop76
Joomla! Intern
Joomla! Intern
Posts: 75
Joined: Sat Dec 25, 2021 10:03 am
Location: Polska
Contact:

Re: Loading a module only if viewed on mobile

Post by pablop76 » Wed Nov 01, 2023 10:35 am

Joomla uses bootstrap 5. So you can use ready-made classes
use responsive display classes for showing and hiding elements
Paweł
Company website: https://web-service.com.pl/
- Joomla passionate, Polska, Skierniewice


Post Reply

Return to “Administration Joomla! 3.x”