Note: Remove the backslashes from the (:\css:)
and (:\cssend:)
directives when using this code!
(:comment This view selector relies on the HttpVariables and CSSInWikiPages recipes.:) (:comment Depending on which view is set, the container has a different class, letting us style its contents on the basis of the view.:) (:\css:) #view_container.view_one { color: red; } #view_container.view_two { color: green; } #view_container.view_three { color: blue; } (:\cssend:) (:comment We set the default view, for new visitors to the page.:) (:default_view: one:) (:comment We set a cookie, so active view is preserved between visits. Cookie path should be to the current page.:) (:if ! equal {$^data_view} "":) (:cookie path="/Main/WikiSandbox" data_view {$^data_view} :) (:else:) (:cookie path="/Main/WikiSandbox" data_view {$:default_view} :) (:ifend:) (:comment The selector passes the desired view as a GET parameter.:) [[{$FullName}?data_view=one | One]] | [[{$FullName}?data_view=two | Two]] | [[{$FullName}?data_view=three | Three]] (:comment We set the container class. If the client has passed a GET parameter, or if the client has a cookie stored, we use that. Otherwise, we use the default value.:) (:if ! equal {$^data_view} "":) (:div id='view_container' class='view_{$^data_view}':) (:else:) (:div id='view_container' class='view_{$:default_view}':) (:ifend:) Test (:divend:)