-
-
Notifications
You must be signed in to change notification settings - Fork 61
New feature: menu icons for modules #1538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request.
Files not reviewed (7)
- htdocs/kernel/module.php: Language not supported
- htdocs/modules/pm/xoops_version.php: Language not supported
- htdocs/modules/profile/xoops_version.php: Language not supported
- htdocs/modules/system/blocks/system_blocks.php: Language not supported
- htdocs/themes/xbootstrap5/css/reset.css: Language not supported
- htdocs/themes/xbootstrap5/modules/system/blocks/system_block_mainmenu.tpl: Language not supported
- htdocs/themes/xbootstrap5/style.css: Language not supported
|
Please, less flashy icons for eye protection <3 |
|
You should be able to adjust it locally |
|
@alain01 but it's only to highlight the currently selected module, so it's clear where we are on the menu, especially when you have a lot of modules. Do you think we should remove it? |
|
Ok, not yet tested, maybe tonight. |
|
@cesagonchu BTW, the yellow highlight was added to highlight the icons. Normally it would look like this: |
|
Honestly, I'm not a fan of icon highlighting. To emphasize something, as Alain says, enlarging the font isn't the ideal solution. |
|
The icons are not highlighted in XOOPS, I did it manually in the picture
to draw attention to them
…On Thu, Apr 10, 2025 at 14:02 montuy337513 ***@***.***> wrote:
Honestly, I'm not a fan of icon highlighting.
To emphasize something, as Alain says, enlarging the font isn't the ideal
solution.
I much prefer the second method (changing the background of the active
module to a different color).
Or another idea: change the color of the module name and the icon for the
active module. Use a color opposite the default menu color. It'll look
nicer and won't scratch the retina.
—
Reply to this email directly, view it on GitHub
<#1538 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEV2NTDWQKMHP65QBSQAW32Y2W2LAVCNFSM6AAAAAB22YV3SSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOJUG4YTKOJWGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
*montuy337513* left a comment (XOOPS/XoopsCore25#1538)
<#1538 (comment)>
Honestly, I'm not a fan of icon highlighting.
To emphasize something, as Alain says, enlarging the font isn't the ideal
solution.
I much prefer the second method (changing the background of the active
module to a different color).
Or another idea: change the color of the module name and the icon for the
active module. Use a color opposite the default menu color. It'll look
nicer and won't scratch the retina.
—
Reply to this email directly, view it on GitHub
<#1538 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEV2NTDWQKMHP65QBSQAW32Y2W2LAVCNFSM6AAAAAB22YV3SSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOJUG4YTKOJWGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
;-) |
|
I recognized the highlight color, I know this wasn't going to be the rendering. |
|
@cesagonchu that could be changed, not a problem. Is the blue color in xswatch4 OK for you? or the original xBootstrap theme? |
montuy337513
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check code : ok
|
I've committed it, but improvement suggestions to xbootstrap5 are always more than welcome. |
|
I prefer xswatch4 (Dark mode). |
|
@cesagonchu, add this code to the /themes/xbootstrap5/style.css file: a {
color: #2fa4e7;
text-decoration: none;
}
a:hover,
a:focus {
color: #2196d3;
text-decoration: underline;
}
.text-primary,
.link-primary {
color: #2fa4e7 !important;
}
.text-primary:hover,
.text-primary:focus,
.link-primary:hover,
.link-primary:focus {
color: #2196d3 !important;
}
.btn-primary {
background-color: #2fa4e7;
border-color: #2fa4e7;
}
.btn-primary:hover,
.btn-primary:focus {
background-color: #2196d3;
border-color: #2196d3;
}
.nav-item > a.nav-link {
color: #2fa4e7;
}and let me know if this solves your color issue |
|
@cesagonchu You can also test the "dark" mode of xbootstrap5: The switch is in top-right corner of the website: |
|
Yes, I tested xBootstrap5 and I like the button at the top right that lets you change to a dark theme. |
|
I ask that cause with this feature, you introduce a hard code design in a php file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be optional? Can a block setting be put in place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I could just override system_block_mainmenu.tpl, to not show them.
@alain01 @mambax7 |
Yes but it's design style in the php file (xoops_version.php) |
I wasn't understanding earlier, but I see now. Yes, How do/can website admins/designers change the module's menu icons without having to modify the module files itself? If its not a feature could this be something we can discuss? |
|
Yeeees, yes, you've understood perfectly ;-)
@mambax7 |
|
@alain01 it's up to you - you can continue here, or you can start a topic on xoops.org |
|
@ihackcode the icons are an option for the module developers to provide default icons, if they want. |
|
@ihackcode BTW - somebody on the Facebook suggested a "multi-layer" approach: that was done by @tad0616 I'm not sure what it exactly means, but if it makes sense and is helpful, there might be some changes/improvements to it |
|
Layer overlay. In our example, a Smarty filter can be applied to the output to add icons if the option is enabled, for example, in the admin. |
Humm sorry to insist, I hope you're all convinced not to put design back into php code... |
|
@alain01 said:
You don't have to do it. The values in the xoops_version.php are just the default values for the icons. Now, as a theme designer, you can: a) ignore the icons altogether, as it is now in the xswitch4 theme: \themes\xswatch4\modules\system\blocks\system_block_mainmenu.tpl <ul class="nav flex-column">
<li class="nav-item<{if empty($block.nothome)}> active<{/if}>"><a class="nav-link" href="<{xoAppUrl}>" title="<{$block.lang_home}>"><span
class="fa-solid fa-home"></span> <{$block.lang_home}></a></li>
<!-- start module menu loop -->
<{foreach item=module from=$block.modules|default:null}>
<li class="nav-item<{if !empty($module.highlight)}> active<{/if}>">
<a class="nav-link" href="<{$xoops_url}>/modules/<{$module.directory}>/" title="<{$module.name}>"><span class="fa-solid fa-check<{if !empty($module.highlight)}>-square-o<{/if}>"></span>
<{$module.name}>
</a>
<ul>
<{foreach item=sublink from=$module.sublinks|default:null}>
<li>
<a class="dropdown" href="<{$sublink.url}>" title="<{$sublink.name}>"><{$sublink.name}></a>
</li>
<{/foreach}>
</ul>
</li>
<{/foreach}>
<!-- end module menu loop -->
</ul> b) use the default icons, as it now in xBootstrap5: <ul class="nav flex-column">
<li class="<{if !$block.nothome|default:''}>active<{/if}>"><a href="<{xoAppUrl ' '}>" title="<{$block.lang_home}>">
<span class="fa-solid fa-home"></span> <{$block.lang_home}></a></li>
<!-- start module menu loop -->
<{foreach item=module from=$block.modules|default:null}>
<li class="nav-item<{if $module.highlight|default:false}> active<{/if}>">
<a class="nav-link" href="<{$xoops_url}>/modules/<{$module.directory}>/" title="<{$module.name}>"><span class="<{$module.icon}>"></span>
<{$module.name}>
</a>
<ul class="no-bullets">
<{foreach item=sublink from=$module.sublinks|default:null}>
<li>
<a class="dropdown" href="<{$sublink.url}>" title="<{$sublink.name}>"><span class="<{$sublink.icon}>"></span> <{$sublink.name}></a>
</li>
<{/foreach}>
</ul>
</li>
<{/foreach}>
<!-- end module menu loop -->
</ul>c) in the code above from xBootstrap5, you can add a check for a particular module by using |
|
OK, ‘a’ and ‘b’ are insignificant for me because we're back to the case of displaying or not displaying, as I explained earlier. A code like that ? (May be it's not correct) : Humm there is a loop (<{foreach item=sublink...) so the code to overload is very bad cause I need to add a test on each submenu and all tests will be done at each "round". |
The solutions are actually simple: I respect the sacrosanct separation of HTML/CSS/JS. Yes, I understand, you have modules with their own icons. But it's not up to the core to adapt to modules or themes. It's not up to the themes to adapt to modules. And it's a bit hypocritical to say that you shouldn't touch PHP and put everything in templates. If you want to adapt Xoops, themes, and modules to the client's needs, in the vast majority of cases, you have to get your hands dirty. Two simple cases: you change the label of a form field = you've forked the module. If you're not careful during the next update (in two years), you lose your changes. You want to modify a module's override TPL in the theme, okay, It's simple. But the next time you update the theme, if the theme has the overrides for this module natively, you'll lose your changes to the tpl file. And this also applies if, to simplify the interface, you want to set a select field to hidden, because the client will always have the box checked. The next time you update the module, goodbye to the changes. The goal isn't to create forks of Xoops/Modules every time a site is created for a demanding client. Maintenance will quickly become unmanageable, or we'll end up with a site frozen in time. In reality, it's the end client who has the final say. And if the end client wants to standardize all the icons on their site to their graphic charter, that's their right. |
|
@alain01 you can create icon config file for modules in your theme, e.g. '/themes/mytheme/config/module_icons.php': <?php
// themes/mytheme/config/module_icons.php
return [
// Key is the module directory name (e.g., 'profile')
'profile' => [
'main' => 'fa-solid fa-id-card', // Overrides $modversion['icon']
'sub' => [
// Key matches the index in $modversion['sub']
1 => 'fa-solid fa-user-pen', // Overrides $modversion['sub'][1]['icon']
2 => 'fa-solid fa-cog', // Overrides $modversion['sub'][2]['icon']
// Add more sublink overrides as needed
],
'news' => [
'main' => 'fa-solid fa-newspaper',
// 'sub' => [... ] // Optional sublink overrides for news
],
//... overrides for other modules...
];Then you can include this file in the $iconOverrides = include __DIR__ . '/config/module_icons.php';
$xoopsTpl->assign('iconOverrides', $iconOverrides);Finally, when iterating through the modules in '/themes/mytheme/modules/system/blocks/system_block_mainmenu.tpl', you check if an override exists in the loaded theme configuration for the current module's directory name. If an override for the main icon ('main') is found, it replaces the $icon value retrieved from $modversion['icon']. Similarly, when processing sublinks, it checks for overrides in the 'sub' array using the corresponding index (e.g., 1, 2, 3) and replaces the $sublink['icon'] value if found. This ensures theme icons take precedence over module defaults. <a class="nav-link" href="<{$xoops_url}>/modules/<{$module.directory}>/" title="<{$module.name}>">
<span class="<{if isset($iconOverrides[$module.directory].main)}>
<{$iconOverrides[$module.directory].main}>
<{else}>
<{$module.icon}>
<{/if}>"></span>
<{$module.name}>
</a>
and then a similar approach for the sublinks, something like: <ul class="no-bullets">
<{foreach item=sublink key=subKey from=$module.sublinks|default:null}>
<li>
<a class="dropdown" href="<{$sublink.url}>" title="<{$sublink.name}>">
<span class="<{if isset($iconOverrides[$module.directory].sub[$subKey])}>
<{$iconOverrides[$module.directory].sub[$subKey]}>
<{else}>
<{$sublink.icon|default:''}>
<{/if}>"></span>
<{$sublink.name}>
</a>
</li>
<{/foreach}>
</ul>Note: The code above was not tested, but it should give an idea how to approach it |
|
Haaaaaaaa I test it and come back ;-) |
|
ok, I added a "]" on '/themes/mytheme/config/module_icons.php' => but I get this error :
file theme_autorun.php: |
|
@alain01 yes, the <?php
// themes/mytheme/config/module_icons.php
return [
// Key is the module directory name (e.g., 'profile')
'profile' => [
'main' => 'fa-solid fa-id-card', // Overrides $modversion['icon']
'sub' => [
// Key matches the index in $modversion['sub']
1 => 'fa-solid fa-user-pen', // Overrides $modversion['sub'][1]['icon']
2 => 'fa-solid fa-cog', // Overrides $modversion['sub'][2]['icon']
// Add more sublink overrides as needed
],
'news' => [
'main' => 'fa-solid fa-newspaper',
// 'sub' => [... ] // Optional sublink overrides for news
],
//... overrides for other modules...
],
];Now to make all of this work, just add this line to "
So you have: <?php
xoops_load('XoopsFormRendererBootstrap5');
XoopsFormRenderer::getInstance()->set(new XoopsFormRendererBootstrap5());
global $xoopsTpl;
$iconOverrides = include __DIR__ . '/config/module_icons.php';
$xoopsTpl->assign('iconOverrides', $iconOverrides);Now this should override the original icons to the ones that you have defined in the If you comment out these 3 lines in <?php
xoops_load('XoopsFormRendererBootstrap5');
XoopsFormRenderer::getInstance()->set(new XoopsFormRendererBootstrap5());
// global $xoopsTpl;
// $iconOverrides = include __DIR__ . '/config/module_icons.php';
// $xoopsTpl->assign('iconOverrides', $iconOverrides);You'll be back to the original icons defined in the |
|
What about the idea of overriding based on $sublink.url. If some sublinks are only shown based on permissions (like a submit article link), I don't think the index number will be correct. |
|
@ihackcode Good point! Any suggestions? |
|
Would an associative array be better? We could use the url as the key and possibly add more items to the submenu array. |
|
@ihackcode to make it work, we need to use the
<?php
return [
'profile' => [
'main' => 'fa-solid fa-id-card',
'sub' => [
// Use the URL as the key
'edituser.php' => 'fa-solid fa-pen',
'search.php' => 'fa-solid fa-magnifying-glass',
'changepass.php' => 'fa-solid fa-rotate',
],
],
'publisher' => [
'main' => 'fa-solid fa-book',
'sub' => [
'search.php' => 'fa-solid fa-magnifying-glass',
'submit.php?op=add' => 'fa-solid fa-calendar-days',
'archive.php' => 'fa-solid fa-pen',
],
],
];
<ul class="nav flex-column">
<li class="<{if !$block.nothome|default:''}>active<{/if}>">
<a href="<{xoAppUrl ' '}>" title="<{$block.lang_home}>"> <span class="fa-solid fa-home"></span> <{$block.lang_home}>
</a>
</li>
<{foreach item=module from=$block.modules|default:null}>
<li class="nav-item<{if $module.highlight|default:false}> active<{/if}>">
<a class="nav-link" href="<{$xoops_url}>/modules/<{$module.directory}>/" title="<{$module.name}>">
<span class="<{if isset($iconOverrides[$module.directory].main)}>
<{$iconOverrides[$module.directory].main}>
<{else}>
<{$module.icon|default:'fa-solid fa-caret-right'}>
<{/if}>"></span>
<{$module.name}>
</a>
<ul class="no-bullets">
<{foreach item=sublink from=$module.sublinks|default:null}>
<{assign var=stripPrefix value=$xoops_url|cat:'/modules/'|cat:$module.directory|cat:'/'}>
<{assign var=subKey value=$sublink.url|replace:$stripPrefix:''}>
<li>
<a class="dropdown" href="<{$sublink.url}>" title="<{$sublink.name}>">
<span class="<{if isset($iconOverrides[$module.directory].sub[$subKey])}>
<{$iconOverrides[$module.directory].sub[$subKey]}>
<{else}>
<{$sublink.icon|default:'fa-solid fa-caret-right'}>
<{/if}>"></span>
<{$sublink.name}>
</a>
</li>
<{/foreach}>
</ul>
</li>
<{/foreach}>
</ul>Original icons for non-Admin:Custom icons for non-AdminCustom icons for Admin: |
|
@ihackcode I didn't see your post, as I was busy testing and then writing my response, but it looks like great minds think alike, since we both came to the same conclusion to use |
|
@mambax7 Looks good. |
|
Ok, I test again and come back ASAP.
Nice think, ihackcode ! And thank you, Mamba and ihackcode to work again to find a solution. |
|
My last question (I hope): |
|
@alain01 It should work, but in the future we'll be probably using custom $modversion['hasMain'] = 1;
$modversion['icon'] = 'fa-solid fa-user';
if ($GLOBALS['xoopsUser']) {
$modversion['sub'][] = [
'id' => 'editaccount',
'name' => _PROFILE_MI_EDITACCOUNT,
'url' => 'edituser.php',
'icon' => 'fa-solid fa-wrench',
];
$modversion['sub'][] = [
'id' => 'search',
'name' => _PROFILE_MI_PAGE_SEARCH,
'url' => 'search.php',
'icon' => 'fa-solid fa-magnifying-glass',
];
$modversion['sub'][] = [
'id' => 'changepass',
'name' => _PROFILE_MI_CHANGEPASS,
'url' => 'changep anything.php',
'icon' => 'fa-solid fa-key',
];
} |
|
Ok, I understand. |










By adding Font Awesome icons to module and submenu items in xoops_version.php:
you can have now in xbootstrap5 theme individual icons for the menu items:

What do you think?