Alternative Specific Users Only

By Timothy Foster Timothy Foster

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!

rating: +7
Shortcut
Joshua Darby Joshua Darby 19 Jan 2016 21:29

I have found that this works a lot better:

[[include :snippets:alt-suo |unique=first |type=showto |user1=joshua-darby]]
[[module NewPage category="blog" parent="blog:_start" button="New post" size="25"]]
[[=]]
**__Admin__**
[[button edit text="Edit page"]]
[[button print text="Print page"]]
[/nav:top/edit/true Edit topbar menu]
[/nav:side/edit/true Edit sidebar menu]
[/system:list-all-categories Page categories]
[/system:recent-changes Recent changes] 
[/admin:themes Change theme]
[[[/_admin|Manage site]]]
**__Help__**
[/help Wiki syntax]
[/modules-reference Modules reference]
[[/=]]
[[/div]]

This example is taken from my personal blog
by Joshua Darby Joshua Darby , 19 Jan 2016 21:29
Re: Shortcut
Helmut_pdorf Helmut_pdorf 20 Jan 2016 08:01

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 ?

by Helmut_pdorf Helmut_pdorf , 20 Jan 2016 08:01
Re: Shortcut
Joshua Darby Joshua Darby 21 Jan 2016 05:10

I meant in terms of just using the showto part

by Joshua Darby Joshua Darby , 21 Jan 2016 05:10
Enrique Santos Enrique Santos 29 Jul 2014 16:09

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:

<divclass="list-pages-box"></div><divclass="suo-specific-class suo-enrique-santos suo-normaluser"><p>.</p></div>

(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).

Last edited on 29 Jul 2014 17:56 by Enrique Santos
by Enrique Santos Enrique Santos , 29 Jul 2014 16:09
RobElliott RobElliott 29 Jul 2014 16:46

the Community site works fine because of CSS

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.

Last edited on 29 Jul 2014 16:48 by RobElliott
by RobElliott RobElliott , 29 Jul 2014 16:46
Enrique Santos Enrique Santos 29 Jul 2014 18:09

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.

by Enrique Santos Enrique Santos , 29 Jul 2014 18:09
RobElliott RobElliott 29 Jul 2014 18:29

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:

/* TOP BAR
==============================*/

#top-bar {
border-radius: 5px;
-moz-border-radius:5px;
-webkit-border-radius: 5px;
background-color:transparent;
border:none;
bottom: 5px;
font-weight: bold;
padding-left: 1em;
top:170px;
width:800px;
right: 0;
}

#top-bar a {
color: white;
}

#top-bar li {
margin: 0;
}

#top-bar li a {
color:#c10000;
padding: 3px 1em;
}

#top-bar ul li ul li a {
border: none;
/*border-bottom: 1px solid #FFF;*/
}

#top-bar ul li a {
background-color:transparent;
border:none;
}

#top-bar ul li:hover a {
background-color:#f9f9f9;
color: #507AA7;
}

#top-bar ul li ul {
font-weight: normal;
border: 1px solid #c7d1b6;
}

#top-bar ul li ul li a {
border: none;
}

#top-bar ul li ul li a:hover {
background-color: #999999;
color: #ffffff;
text-decoration: none;

}

#top-bar ul li.sfhover ul li:hover a {
background-color:#999999;
color:#ffffff;
border-left:3px solid #c10000;
}

#top-bar ul li.sfhover ul a {
background-color: #f1f1f1;
width:10.5em;
}

#top-bar ul li.sfhover ul {
width:12.5em;
border: 1px solid silver;
}

and the nav top syntax is:

* [# New here?]
 * [[[Getting Started]]]
 * [http://www.wikidot.com/doc:start FAQ]
 * [http://www.wikidot.com/faq:editing-pages How to edit pages?]
 * [[[system:Join|Join the Community]]]
 * [[[GuestBook|Sign the guestbook]]]
 * [[[Your status]]]
 * [[[What is a wiki site?]]]
 * [*http://www.wikidot.com/legal:terms-of-service Terms of Service]
* [# Doc & Help]
 * [[[help:emergency-help |Emergency Help]]]
 * [[[help:start|Getting help]]]
 * [[[help:glossary|Glossary]]]
 * [[[helpon:_start|HelpOn A-Z]]]
 * [[[howto:_start|How-To's]]]
 * [*http://101.wikidot.com Video Tutorials]
 * [*http://livesupport.wikidot.com/ Live Support]
 * [*http://convert.wikidot.com/ Data Form Fixer]
 * [*http://www.wikidot.com/doc Documentation]
 * [*http://handbook.wikidot.com/ Handbook]
 * [*http://livesupport.wikidot.com/ Live Support]
 * [*http://community-playground.wikidot.com/ Playground]
 * [[[Showcase]]]
 * [*http://snippets.wikidot.com Snippets]
 * [*http://themes.wikidot.com/ Themes]
 * [*http://www.wikidot.com/doc:wiki-syntax Wiki Syntax]
* [# News]
 * [[[blog:_start| Community Blog]]]
 * [[[app:_start| Applications]]]
 * [*http://blog.wikidot.com Wikidot Blog]
 * [*http://news.wikidot.com Wikidot News]
 * [[[press:_start|Press notices]]]
 * [[[syntax-changes |Syntax changes]]]
 * [[[featured:_start|Featured sites]]]
 * [[[stories:_start | Wikidot stories]]]
 * [[[forum:minirecent-threads |Recent threads]]]
 * [[[forum:minirecent-posts | Minirec.100 posts]]]
 * [*http://www.wikidot.com/ Wikidot (Home)]
* [# Improve Wikidot]
 * [*http://feedback.wikidot.com/wish:_all Feature Requests]
 * [*http://feedback.wikidot.com/bugs:_all Bug Reports]
 * [*http://translate.wikidot.com/ TRANSLATE Wikidot]
 * [*http://projects.wikidot.com Projects]
 * [*http://roadmap.wikidot.com Roadmap]
 * [[[Corrections]]]
 * [*http://spambotdeathwall.wikidot.com/ SpambotDeathWall]
[[include :snippets:suo START unique=first|type=hidefrom
|user1=ed-johnson
|user2=gerdami
|user3=hartnell
|user4=helmut-pdorf
|user5=james-kanjo
|user6=leiger
|user7=michal-frackowiak
|user8=phil-chett
|user9=pieterh
|user10=robelliott
|user11=scottplan
|user12=steven-heynderickx
|user13=tsangk
|user14=timothy-foster]]
* [# Internals]
 * [[[system:candidate-for-delete| Candidate for Delete]]]
 * [*http://chatroom.wikidot.com/chatroom Chatroom]
 * [[[system:list-all-categories | List all Categories]]]
 * [[[system:Orphaned-pages |Orphaned Pages ]]]
 * [[[system:Page Calendar]]]
 * [[[system: Page Tags]]]
 * [[[system:page-tags-list|Page Tags List]]]
 * [[[system: Recent changes]]]
 * [[[system:members | Site members]]]
 * [[[user:_activity | User Activities]]]
 * [[[system:wanted-pages |Wanted Pages ]]]
[[include :snippets:suo END]]
[[include :snippets:suo START unique=second|type=showto
|user1=ed-johnson
|user2=gerdami
|user3=hartnell
|user4=helmut-pdorf
|user5=james-kanjo
|user6=leiger
|user7=michal-frackowiak
|user8=phil-chett
|user9=pieterh
|user10=robelliott
|user11=scottplan
|user12=steven-heynderickx
|user13=tsangk
|user14=timothy-foster]]
* [# Internals]
 * [*http://admindevelopement.wikidot.com/forum:recent-posts Admin Forum]
 * [[[admin:_manage|]]]
 * [*http://backupstorage.wikidot.com/ Backupstorage]
 * [[[system:candidate-for-delete| Candidate for Delete]]]
 * [*http://chatroom.wikidot.com/chatroom Chatroom]
 * [[[Files]]]
 * [[[system:list-all-categories | List all Categories]]]
 * [[[system:Orphaned-pages |Orphaned Pages ]]]
 * [[[system:Page Calendar]]]
 * [[[system: Page Tags]]]
 * [[[system:page-tags-list|Page Tags List]]]
 * [[[system: Recent changes]]]
 * [[[nav:side | Side bar menu]]]
 * [[[admin:manage|Site Manager]]]
 * [[[system:members | Site members]]]
 * [[[nav:top | Top bar menu]]]
 * [[[user:_activity | User Activities]]]
 * [[[system:wanted-pages |Wanted Pages ]]]
[[include :snippets:suo END]]
[[div style="position:fixed; right: 0pt; bottom: 0pt; z-index:50"]]
[[button edit-sections text=" " style="background-image: url(http://commons.wikimedia.org/wiki/Image:Blank_space.png); background-repeat: no-repeat; background-position: bottom right; padding-right: 20px; background-color: transparent"]]
[[/div]]

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.

Last edited on 29 Jul 2014 18:49 by RobElliott
by RobElliott RobElliott , 29 Jul 2014 18:29
Enrique Santos Enrique Santos 29 Jul 2014 18:39

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.

by Enrique Santos Enrique Santos , 29 Jul 2014 18:39
RobElliott RobElliott 29 Jul 2014 18:46

See the additions to my post above.


Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.

by RobElliott RobElliott , 29 Jul 2014 18:46
Not perfect (yet)
Enrique Santos Enrique Santos 26 Jul 2014 20:45

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.

by Enrique Santos Enrique Santos , 26 Jul 2014 20:45
Re: Not perfect (yet)
Timothy Foster Timothy Foster 26 Jul 2014 22:28

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:

[[include :snippets:alt-suo |unique=normalusers |type=hidefrom |user=enrique-santos]]
* [/ Portada]
* [# Acerca de]
 * [/main:bienvenida Bienvenida]
 * [/main:criterios Criterios]
 * [/main:motivacion Motivación]
 * [/system:members Miembros]
* [/blog:_start Artículos]
[!-- * [/docs:_start Documentación]
* [/wiki:_start Wiki]
--]
* [# Acciones]
 * [[button edit text="Modificar página"]]
 * [[button print text="Imprimir página"]]
* [# Ayuda]
 * [/help Sintaxis wiki]
 * [/modules-reference Referencia de módulos]
[[include :snippets:alt-suo]]
[[include :snippets:alt-suo |unique=admins |type=showto |user=enrique-santos]]
* [/ Portada]
* [# Acerca de]
 * [/main:bienvenida Bienvenida]
 * [/main:criterios Criterios]
 * [/main:motivacion Motivación]
 * [/system:members Miembros]
* [/blog:_start Artículos]
[!-- * [/docs:_start Documentación]
* [/wiki:_start Wiki]
--]
* [# Acciones]
 * [[button edit text="Modificar página"]]
 * [[button print text="Imprimir página"]]
* [# Ayuda]
 * [/help Sintaxis wiki]
 * [/modules-reference Referencia de módulos]
* [# Administración]
 * [/nav:top/edit/true Modificar el menú]
 * [/system:list-all-categories Ver por categorías]
 * [/system:paginas-ocultas Páginas ocultas]
 * [/admin:themes Temas visuales]
 * [/_admin Administrar sitio]
[[include :snippets:alt-suo]]

Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me

by Timothy Foster Timothy Foster , 26 Jul 2014 22:28
Re: Not perfect (yet)
Enrique Santos Enrique Santos 27 Jul 2014 19:36

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.

by Enrique Santos Enrique Santos , 27 Jul 2014 19:36
Re: Not perfect (yet)
Enrique Santos Enrique Santos 28 Jul 2014 19:21

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:

TwQGWOT.png

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.

by Enrique Santos Enrique Santos , 28 Jul 2014 19:21
Re: Not perfect (yet)
RobElliott RobElliott 28 Jul 2014 19:25

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.

by RobElliott RobElliott , 28 Jul 2014 19:25
Re: Not perfect (yet)
Timothy Foster Timothy Foster 28 Jul 2014 22:41

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

Last edited on 28 Jul 2014 22:42 by Timothy Foster
by Timothy Foster Timothy Foster , 28 Jul 2014 22:41
Re: Not perfect (yet)
Timothy Foster Timothy Foster 29 Jul 2014 00:15

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

by Timothy Foster Timothy Foster , 29 Jul 2014 00:15
Re: Not perfect (yet)
Enrique Santos Enrique Santos 29 Jul 2014 00:58

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?)

by Enrique Santos Enrique Santos , 29 Jul 2014 00:58
Re: Not perfect (yet)
Helmut_pdorf Helmut_pdorf 27 Jul 2014 07:23

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 ?

by Helmut_pdorf Helmut_pdorf , 27 Jul 2014 07:23
Re: Not perfect (yet)
Enrique Santos Enrique Santos 27 Jul 2014 19:48

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.

by Enrique Santos Enrique Santos , 27 Jul 2014 19:48
Re: Not perfect (yet)
Helmut_pdorf Helmut_pdorf 28 Jul 2014 06:27

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 ?

by Helmut_pdorf Helmut_pdorf , 28 Jul 2014 06:27
page revision: 3, last edited: 11 Dec 2013 18:04
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).

AltStyle によって変換されたページ (->オリジナル) /