Link to the mod (https://custom.simplemachines.org/index.php?mod=4336)
Description:
The SMF Theme Toggle mod lets you easily toggle between the forum default theme and an admin-designated secondary theme with a single click.
This mod works with any theme that allows new entries in the main & profile menus.
This mod works whether or not javascript is enabled on the client.
The requested change is persistent; it works by updating the user's requested theme on their profile. Users must be allowed to select themes.
Note that menus are cached; you may need to clear cache for this mod to take effect.
Releases:
- v1.0 Initial release
- v1.1 Allow admin to select profile menu or main menu
Very nifty Shawn.
Can you consider making it so each member can toggle between their two favorite themes in a future version?
Yep, that's a definite maybe!
The other suggestion I've received is placing it on the profile menu vs the main menu, or making the location an option.
The point was to make it easy to switch to dark mode, in one click, as I've seen on some other sites.
I know this is beyond the scope of the current iteration... but would you consider perhaps allowing more than just a toggle between two themes? My forum runs a total of 5 themes... clicking that button and providing a drop down to select between them would make this mod a 'must have' for my forum...
Just something to consider.
It does work nicely as advertised already. Thank you.
That would make the mod a theme changer rather than a toggle between two themes, yes? :)
What is a toggle other than a theme changer but for two themes?
8)
And that's the point, toggling between two things only.
There are theme changer mods out there, either standalone or part of the portal mods.
...but none as elegant. Again...`twas just a suggestion. FWIW, I run Tiny Portal currently for the sole reason of the theme changer. Not elegant.
Quote from: shawnb61 on June 24, 2022, 12:55:45 PMYep, that's a definite maybe!
The other suggestion I've received is placing it on the profile menu vs the main menu, or making the location an option.
The point was to make it easy to switch to dark mode, in one click, as I've seen on some other sites.
I like it
Is there a way to allow visitors to change the themes? I'm alternating between light and dark.
Quote from: shawnb61 on June 24, 2022, 12:55:45 PMYep, that's a definite maybe!
The other suggestion I've received is placing it on the profile menu vs the main menu, or making the location an option.
The point was to make it easy to switch to dark mode, in one click, as I've seen on some other sites.
I customized a "copy" of the curve2 theme in dark mode.
Original: https://amigosdaeletronica.com.br
Your MOD is excellent and works well on my official forum.
I would just like permission for visitors!
This image is the "tests" forum with change by the portal.
Test: https://amigosdaeletronica.com/
I forgot the image
Capturar.PNG
I will look into guest support at some point. I am in the middle of a few other things I'm looking at atm, so it might be a while.
Quote from: FrizzleFried on June 24, 2022, 03:38:09 PM...but none as elegant. Again...`twas just a suggestion. FWIW, I run Tiny Portal currently for the sole reason of the theme changer. Not elegant.
https://custom.simplemachines.org/index.php?mod=3356 - works perfectly and can be placed at the top or bottom of the forum. A small css change can make it centered as well.
Hi,
I would like to place the theme tog button somewhere else in the menu (outside top dropmenu and thus the burger menu on mobile devices). But for the life of me, I cannot find where the themetog function is placed in which php file. I've looked into index.template, Display, and Subs.php to no avail. Any help would be appreciated!
Since this mod is 100% hooks, there isn't an update made to a theme file for you to tweak. The arrays that contain the menu entries are manipulated directly via hook.
The current approach is to update the main menu $buttons array via the integrate_menu_buttons hook:
https://github.com/sbulen/SMF-Theme-Toggle/blob/fb788b8f0ae1e4244ba123f5889e532d10527d5c/dist/Sources/ThemeToggleHooks.php#L39
I believe you will want to update the $profile_areas array via the integrate_profile_areas hook.
Then test the bejeebers out of it...
v1.1 of this mod allows you to place the theme toggle button in the user profile menu.
At the moment, I'm having some challenges placing this new version on the customization site.
Until this is resolved, feel free to download v1.1 here:
Thank you so much,
@shawnb61, for making the effort adding it to the menu, really unexpected and appreciated!
I now realize, though, I might have been a bit imprecise in my "request" recently. My intention was to have the toggle button sitting next to the alert and pm buttons (bell & envelope) so it could be readily accessed on mobile, too, without requiring the user to go to a menu first - just like those two. I use Fontawesome icons for these, so it would fit quite nicely on a mobile screen.
Note you no longer need to use the link above. The link to the mod will now allow you to download the latest version.