Specific Notification System

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:

  1. after sending a message via the MailForm module*
  2. 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.

*Caveats

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.

In action

Want to see the message in action? Well, you can send me a hello via the contact page, or just visit this link instead.

Enjoy the article? Tweet it!

Discussion - 1 comments

James Kanjo avatar

AnonymousJames Kanjo 25 Apr 2011 09:42

Fantastic use case of the ListPages module!!! Well done!!!

Edit

Add a new comment

Site design © BMC WebDesign, 2011. All rights reserved. All tutorials on this site are free for commerical use, subject to conditions outlined in the disclaimer.