25 Apr 2011 01:53
25 Apr 2011 01:53
Specific Notification System
Customised user messages the Wikidot way.
The premise is simple — you want to show a message to a user based on an action they have just performed. Ordinarily, you would create a new page containing the message, and perhaps some links to lead them elsewhere in the site. While this solution works just fine, it's not as streamlined as being able to show the message on an existing page of your site that the user would probably click through to anyway. Enter my Specific Notification System.
As always, the idea came to me just as I was dozing off to sleep, meaning I had to get up and act on it straight away, else I would never get some shut-eye. The system uses the recently revised limit="0" ListPages parameter to only show a message if a specific string is included in the URL, something we can control when a user completes a certain action.
So, to start things off, we setup a ListPages module with limit="@URL|0" - meaning by default no module body will be shown. Which page you select doesn't really matter, given we're not going to be using anything from the selected page itself. I also added a URL attribute prefix so as not to confuse other modules on the same page.
[[module ListPages category="blog" limit="@URL|0" urlAttrPrefix="i" separate="no"]] [!-- Define message here --] [[/module]]
Now, to display the message, all we need to do is append /i_limit/1 to the URL of the page, and voila - the message appears!
Where to use?
Currently, I can only think of two situations where we can define the URL a user is sent to after completing an action:
- after sending a message via the MailForm module*
- after joining the site as a member
If you can think of any others, I'd love to know about them in the comments section below.
The MailForm module doesn't support redirecting to a page with URL arguments, so instead you have to send it to a page that contains a Redirect module.
Edit: This has been fixed and you can now use successPage="mypage/i_limit/1" in the Mailform module directly.
Enjoy the article? Tweet it!