Description
The original Specific Users Only CSI was engineered by James Kanjo. This include allows Wikidot users to hide or show data based on who is currently logged on. This means you can easily hide certain administrative links from common viewers.
The original CSI works brilliantly, but this alternative version attempts to eliminate some of the limitations the original had. Namely:
- Modules (like NewPage and ListPages) may be used within the SUO body
- Live Template variables may be used within the SUO body
- In hidefrom mode, anonymous users will see the information
Syntax
The syntax is the same as for the original SUO. However, the Alternative SUO is now always in "advanced" mode, meaning you can use ListPages variables to define users (like %%created_by_unix%%).
Attribute | Default Value | Description |
---|---|---|
type | Required! | Either showto or hidefrom. This specifies whether to show or hide data from the listed users. |
unique | default | Required when using multiple SUOs on a single page. Can be any alphanumeric sequence with hyphens, not do NOT use spaces. |
user | none | The UNIX name of a user to which data will be shown to (or hidden from if in hidefrom mode). Being a UNIX name, no spaces are allowed, and all letters should be lowercase. In place of spaces, use hyphens. |
user0 | … | Same as above |
user1 | … | … |
… | … | … |
user99 | … | Supports up to 101 users. |
Code
[[include :snippets:alt-suo |unique=first |type=showto |user1=timothy-foster |user2=michal-frackowiak]]
**Hello Timothy Foster & Michał Frąckowiak!!!**
[[/div]]
[[include :snippets:alt-suo |unique=second |type=hidefrom |user1=timothy-foster |user2=michal-frackowiak]]
**Hello Everybody Else!!!**
[[/div]]
Note: The ending [[/div]] can be replaced with the following in order to be compatible with how the original SUO works:
[[include :snippets:alt-suo]]
In action
Hello Timothy Foster & Michał Frąckowiak!!!
Hello Everybody Else!!!
Important
While this alternative eliminates some of the limitations of the original, it still has the limitation that it cannot be used within modules itself.
Thanks to tsangk for this great snippet: conditional-blocks
text above inserted with:
[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]
Other snippets posted by Timothy Foster
Fancy HR Dividers - 07 Apr 2021 06:23
Carousel - 24 May 2015 01:18
Modal Image - 01 May 2015 17:20
Bootstrap Image Box - 19 Jul 2014 01:27
Togglecheck - 17 Dec 2013 20:27
Image Box - 10 Dec 2013 03:14
Toggle Tag - 19 Jul 2013 11:13
Hide Tags - 14 Feb 2013 21:35
Plurality Checker - 16 Jul 2012 03:21
Mini Chat Area - 15 May 2012 12:04
Table Alterations - 16 Feb 2012 01:45
Rate this solution
If you think this solution is useful — rate it up!
I have found that this works a lot better:
This example is taken from my personal blog
Joshua Darby
Wikidot Support Mentor | Icon Deposit Profile
Yes, we are using this also on our community top bar menu: http://community.wikidot.com/nav:top
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
I meant in terms of just using the showto part
Joshua Darby
Wikidot Support Mentor | Icon Deposit Profile
Ok, I analysed it further. The 'suo' snippet is working properly, it generates a [[div class="suo-specific-class …"]], so that the wiki interpreter closes the previous <ul>, and a new <ul> is opened (in the menu example).
So it seems not possible to keep on the same <li> chain with a 'suo' snippet inside :-( (the Community site works fine because of CSS, but the submenu "Internals" is on another <ul>, not in the same as the rest of submenus).
Anyway, the 'alt-suo' snippet adds the following extra output before the main 'alt-suo' div, in fact there are two "suo-specific-class" divs for each snippet in the source:
(sometimes a different output, probably Timothy is working on it, thumbs up!).
I'm using the solution proposed by Timothy with 'alt-suo' snippet, it works fine ('suo' doesn't show anything to anonymous users).
There were no css changes made on the community site to accommodate the suo snippet.There are just 2 suo snippets one after the other with different menu options: one for normal users using hidefrom plus the names of the admins, and one for normal users using showto plus the names of the admins.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
I mean that the CSS of Community site theme allows to show different <ul> on the same menu level, while my theme CSS puts a different <ul> in another line of menu.
I. e., Community site has two <ul> on the main menu, one for most of submenus and another one just for "Internals" submenu. It is just because of CSS visualization that it seems to be only one main menu, while in fact they are two unordered lists, the second one enclosed on his own <div>, indeed.
I wrote the css for the community site and certainly don't recall adding related to the suo. For info the CSS for the top bar is:
and the nav top syntax is:
It's a very old and tired design now and the next version, currently being worked on (I think) by Timothy will be bootstrap/mobile friendly and more modern.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
That CSS is very good, Rob, I just mean about the 'suo' output, about HTML structure that we can not see on the visual output of that site.
See the additions to my post above.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
I tried this solution to hide "Administration" menu to all users except administrator (me). It works quite fine, but not perfectly, because it inserts an empty line before the module, so that "Administration" menu goes to another line down the main menu. I also tried the original SUO snippet, and it has the same problem.
I wish that it is an easy to solve problem.
One thing you can try is to use two of these modules. The first one will use showto to show you the administrative options, and the other will use hidefrom to hide the non-administrative options. Essentially, you would have two copies of the top bar, but one will be viewable by you, and the other will be visible to the public.
The following code should do the trick:
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Near to perfect! :-) , thank you!, this solution works fine.
The small problem now is redundant information and double edition when changing common options in menus, but it works. I just wonder if the module can be corrected easily, or is it an unavoidable effect.
Oh!, not so good :( , this solution doesn't work properly when the page does not exist. In that case both versions of the menu are showed to any user, and both are out of proper position:
I suppose that my CSS theme is not perfect also, but it only shows what exist, so the output of the two consecutive alt-suo snippets is not the desired output.
Something's not right because you can see a closing module code in the image you posted. You might want to consider inviting one of us admins to be a temporary admin of your site to look into this and hopefully solve it. We do this quite a lot and never trash a site and then resign when the issue is resolved.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
It seems like there was a small bug the SUO code. I changed it, and it seems to be behaving properly on my test site now. Is it looking good on yours?
Scratch that; there was a reason I had that code there! I'll look into it further later today.
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
I believe I have alleviated the problem, so it doesn't look as bad; it should display the non-administrative options.
The error was occurring because the snippet depends on a ListPages module that searches for the current page. If the page doesn't exist, then ListPages cannot find that page, and hence certain things fail to hold.
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Great!, now it works as you say: it displays the version with "type=hidefrom" when the page doesn't exist (not the correct, but not a problem). The problem did not arise at the Community site because it uses redirection for non-existent pages.
Thank you, Timothy!
(maybe you could look into the SUO/ALT-SUO code further to see why it outputs an extra empty line at the beginning?)
I would do it like our top-menu in the community forum with a "normal" mdnu point "Internal" and under this menu-string there are different entries for admins and normal users..
This prevents us from this empty line I beleve
Put any "normal" page for normal users in this menu…
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
Helmut, I copy-pasted the source of the top menu in community.wikidot.com (as a test) and the problem is the same, the menu "Internal" goes down, out of the menu bar.
I think that it is the theme CSS on community site which prevents the problem. But the problem is there, you can see the extra line if you look the html page generated with "Preview" when editing.
ok, that is bad if the default/theme CSS is the reason for this extra line.
It is a lot of work to find out where in your used CSS the reason lies….
I think, the solution of Timothy is easier to use. :)
( but you can move the redundant menu-lines put in an extra "include:Nav-top-open" to have it only once…? )
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?