November 26, 2003

Subscribe/Unsubscribe

Probably the most long awaited feature is at last here. The subscribe/unsubscribe feature is now available to all blogs on BensFriends.com. Information about adding it to your own blog is below. If your not interested in digging under the hood, please let me know
.

Lord willing, this feature will help others get involved in growing as a Church.

Here is the technical info behind how all this works and how to add it to your blog:

The dirty under the hood stuff is already done. The only thing left to do in each blog is provide the interface for your users.

First, you'll need to add this code to your side bar (look for 'div id="links"').


<div class="sidetitle">
Subscribe/Unsubscribe
</div>

<div class="side">
<form name="sub" id="sub" method="post" action="<$MTCGIPath$>mt-add-notify.cgi" onsubmit="return checksub()">
<input type="hidden" name="blog_id" value="<$MTBlogID$>" />
<input type="hidden" name="_redirect" value="<$MTBlogURL$>" />
<input type="radio" name="sub_action" value = "subscribe" checked="checked" /> Subscribe
<input type="radio" name="sub_action" value = "unsubscribe" /> Unsubscribe<br/>
<input type="hidden" name="blog_name" value="<$MTBlogName$>" />
<input name="email" size="20" />
<input type="submit" value="Go" />
</form>
</div>

You may customize that as you please.

Next you'll want to add this little piece of JavaScript inside your <script/> tags at the top of the "Main Index" template.


function checksub()
{
var str = sub.email.value;
var re = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/;
if (!re.test(str))
{
window.alert('Invalid email address');
sub.email.focus();
return false;
}
return true;
}

That should do the trick.

Let me know if you need or want anything else.

P.S.: Special thanks to everyone that worked on this hack over at the MT Forums.

Posted by TheIdeaMan at November 26, 2003 03:50 PM | TrackBack