IfCookie
leiger wrote on 06 Apr 2010 06:44
Would it be possible for an "IfCookie" syntax, similar to "IfTags", which allows the ability to check the cookie value outside of a module?
My use case is that I am including a signature in a forum by using this code for each post:
[[include signature:%%created_by%%]]
(The error message for if the page doesn't exist is hidden with CSS)
An "IfCookie" syntax would allow me to do something like this:
[[ifcookie show-signature="yes"]]
[[include signature:%%created_by%%]]
[[/ifcookie]]
[[ifcookie show-signature="no"]]
[[collapsible show="click here to show the signature (auto hidden)" hide="hide signature"]]
[[include signature:%%created_by%%]]
[[/collapsible]]
[[/ifcookie]]
Two questions for Gabrys (or anyone else on the development team):
- Is this easy/hard to implement?
- Can you see any design flaws/areas for improvement in this idea?
Comments: 3
page revision: 0, last edited: 06 Apr 2010 06:44
Answering just your use-case:-
Because cookies are per-browser and not per-user, this would not work.
I believe modules inside ListPages will be here before too long?
(It would work with an include inside ListPages, but it's more obvious written this way.)
I haven't yet seen a good use-case for cookies that global variables were not a better solution for. They're a cool idea, but I can not think what I, or anyone else, would use them for.
If I understand your code correctly… you're writing down a way to detect if someone has created a signature, and to show it if they have? My use case was to allow a single user to determine if he sees those signatures or not (or with cookies, to allow a certain browser to tell the website whether or not to show signatures… which although not perfect is better than having no user control at all)
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Fair enough, but if the cookie was not set, neither paragraph would be displayed. That's actually a fairly important bug, since I think a random new anonymous user wont have the cookie set?