How can I change color and height of the Top Panel Menu?

this extension
Top Panel Menu (XWiki.org)

which by the way, seems to be used by the XWiki Extensions page itself, but in a much more pleasing dark gray tone…

while after installing, it comes in black

I didn´t find it on Theme Modification settings…

Hi @rogerpenna,

On extensions.xwiki.org I’m pretty sure that the menu is built with https://extensions.xwiki.org/xwiki/bin/view/Extension/Menu%20Application. What you discovered is some extension created by somebody in the community and the latest update was done in 2016 and there could be incompatibility surprises when using on the latest XWiki versions. Regarding the style, it was customized to look nice with the installed color theme and you can do the same.

Hope it helps,
Alex

1 Like

Yes, I was even able to install the standard top menu before seeing your reply The standard top menu uses the same color as the top bar, afaik

Hi!

Although as @acotiuga said the top menu in Extensions is built with Menu Application, I would like to fully understand how Top Panel Menu works. It is a pretty simple extension that allows creating nice top menus. I’m able now to create new tabs, groups and list items, but I’m not able to control the visibility scope. @rogerpenna, @acotiuga, @ClemensRobbenhaar, which objects must I instantiate in which pages to get Top Pane Menu loading for all users, included anonymous ones?

Thanks!

Similar to the “Menu” Application shipped with XWiki, the “Top Panel Menu” does not check view rights of the links it produces.

The technical reason behind it is that it uses normal content in XWiki pages to create the menu and normal XWiki pages do not hide links to pages even if the current user has no access to them.

I am not sure how to solve this on the application side. If you are not afraid of lots of copy & paste you can check every list item and only display it if the current user has view rights; i.e. go through every ListItem-XX page, edit it in the wiki editor, and replace every line like:

* [[Label>>doc:Path.To.Space.WebHome]]

by:

#if($services.security.authorization.hasAccess('VIEW', 'Path.To.Space.WebHome'))* [[Label>>doc:Path.To.Space.WebHome]]#end

Afterwards the menu should show only links to pages that are visible to the current user.
In case all entries in a section are not visible, it will still show the empty section, though. One probably would need to restrict the visibility of the corresponding page to exactly the viewers of any of these links.

Hi @ClemensRobbenhaar! Thanks for the detailed answer.

Got it. But what I’m pursuing now is to control the visibility of the whole menu itself. I can control “Menu” Application scope by using the “Menu visibility scope” property available at the concerned tab under “Administer Wiki”. But this is not possible for “Top Panel Menu” to the best of my current understanding. At least in the XWiki instance I’m using now (XWiki Debian 16.5.0) “Top Panel Menu” is available only for logged users, not for anonymous ones. You won’t see the top menu if you go now to https://portal.igfae.usc.es. I can see it when loggged:

image

I don’t know how to control its visibility: I would like to show this simple top menu to all users, anonymous included. Could you help me with this?

Nice. As I’m looking for a very simple top menu, it won’t be hard to change the links so far. It will be also a nice exercise to design a simple counter to hide empty tabs! I will work on that!

Thanks!

Ah, that issue … the visibility of the whole men is currently hard wired.
If you go to the (hidden) page CustomExtension.TopPanelMenu.AfterHeaderUIX
(i.e. .../view/CustomExtension/TopPanelMenu/AfterHeaderUIX) and edit it in the “Object editor”, you can open the “UIExtensionClass 0: org.xwiki.contrib.application-toppanel-menu” object and look at the field “Code”.

In line 2 there is a check for anonymous users:

#if ($xcontext.user != 'XWiki.XWikiGuest' && $doc.fullName != "CustomExtension.TopPanelMenu.Content.WebHome") ## displayed only when a user is log on

Remove the check e.g. by replacing the line with:

#if ($doc.fullName != "CustomExtension.TopPanelMenu.Content.WebHome")

and the menu should be shown to anonymous users, too. (I have not really checked if this works. It is possible some relevant CSS resources in “CustomExtensions” need to be made visible for anonymous users, too)

1 Like

Cool! Done! Thanks!

so you have a particle accelerator at Galiza? Nice.

In Brazil the only two we have is Sirius and UVX
https://lnls.cnpem.br/sirius/

Although off-topic, allow me to reply! After all, we show a XWiki installation! :slight_smile: @rogerpenna, no! We have only a small laser accelerator in Santiago de Compostela. Several other installations in Spain. We build parts for big experiments/infrastructures around the world!

1 Like

Hi! There is a side effect of removing that check:

I guess $doc.fullName calls com.xpn.xwiki.XWikiContext.getDoc() that fails because retrieveusername and resetpassword are not XWiki “pages”.

So, how could we avoid that call and keep checking that the loaded page is not CustomExtension.TopPanelMenu.Content.WebHome?

Thanks!

Oh, I have not thought about that one.

Maybe replacing:

#if ($doc.fullName != "CustomExtension.TopPanelMenu.Content.WebHome")

by:

#if ($doc && $doc.fullName != "CustomExtension.TopPanelMenu.Content.WebHome")

or

#if ($doc != $NULL && $doc.fullName != "CustomExtension.TopPanelMenu.Content.WebHome")

helps.

Easy and nice… when one have skills enough! I will keep learning. Thanks!