Topic on Project:Support desk

How to hide portions of text from site visitors

5
Cavila (talkcontribs)

For the convenience of editors of my site, I’ve added a number of extra links (e.g. semantic forms) to the sidebar. However, because this is rather confusing to regular visitors who have not logged in, I was looking for a way to hide those links from them. Contrary to what is claimed on this page, CustomSidebar does not offer such functionality. As a workaround I was hoping I could embed these links in content pages using Extension:ConditionalShow, but this extension is broken as of 2008/2009.

Any ideas?

Subfader (talkcontribs)

I use CSS for that. Hide by default, but in the skin file add according CSS rules to show it for logged in users.

Cavila (talkcontribs)

Thanks for the tip, but could you elaborate? Although I learned that in MW:Common.css or the skin's CSS you can define a class like

span.hiddentext { display:none; }

to be applied in a page in this way:

<span class="hiddentext">This text is hidden from view.</span>

so that a portion of text is hidden by default, I couldn’t find any CSS techniques to make things appear again for logged-in users.

What I've done instead is to use the 'group sidebar' from Extension:DynamicSidebar in combination with Extension:CustomSidebar.

Subfader (talkcontribs)

You need to edit the skin file, e.g. Monobook.php. If user is logged in (check for userrrights, e.g. "edit") then return

<style type="text/css">
.hiddentext { display:inline !important; }
</style>

Thinking about it again, it would be best to add user status css classes to the body tag. I opened a request for that on bugzilla: https://bugzilla.wikimedia.org/show_bug.cgi?id=34413

Cavila (talkcontribs)

Ah, I see, thanks. I don't use Monobook myself, but there are probably equivalent CSS sections in skins such as those of Gumax that could make it work.

Reply to "How to hide portions of text from site visitors"