Not a developer? Go to MovableType.com

Documentation

Accepting Community Contributed Content

A key component to many community web sites is providing members with the ability to post and contribute content. This article makes references to concepts covered in other articles that you may find helpful. Specifically:

To facilitate the creation of content by community members several key templates are needed. The following article discusses these templates, how they work, and how you can create them. These templates are:

  • Create Entry Template
  • Entry Response Template

Create Entry Template

This template is responsible for generating the form that users will fill out when submitting content. The sample code below is very bare. Feel free to adorn it with whatever HTML and CSS you need in order to make it appear the way you want.

Template Code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
<head>
    <title><$mt:BlogName encode_html="1"$></title>
    <meta http-equiv="Content-Type" content="text/html; charset=<$mt:PublishCharset$>" />
    <script type="text/javascript">
    <!-- 
    function entry_create_loggedin() {
        var u = mtGetUser();
        var loggedin = u && u.is_authenticated && u.is_author ? true : false;
        var eid = 'logged_in';
        conditional_block(loggedin, eid);
        if (!loggedin) {
            var p = document.getElementById('login_message');
            if (!p) return;
            if (u && !u.is_author) 
                p.innerHTML = "In order to create an entry on this blog you must first register.";
            else
                if (u && !u.can_post)
                    p.innerHTML = "You do not have permission to post.";
                else
                    p.innerHTML = '<a href="javascript:void(0)" onclick="return mtSignInOnClick(\'login_message\')">Sign in to create an entry.</a>';
        } else {
            var mt = document.getElementById('magic_token');
            if (mt) mt.value = u.sid;
        }
    }
    //-->
    </script>
    <script type="text/javascript" src="<$mt:Link template="JavaScript"$>"></script>
</head>
<body>

<div id="signin-content">
    <a href="javascript:void(0)" onclick="return mtSignInOnClick('signin-content')">Sign In</a>
</div>

<h3>Navigation</h3>
<ul>
    <li><a href="<$mt:Link template="Homepage"$>">Home</a></li>
    <li><a href="<$mt:Link template="Create Entry"$>">Create Entry</a></li>
</ul>
<!-- end header --><hr />

<h1>Create Entry</h1>
<mt:IfLoggedIn script="entry_create_loggedin" class="foo">
    <form method="post" action="<$mt:CGIPath$><$mt:CommunityScript$>" name="entry_form" 
          id="create-entry-form" enctype="multipart/form-data">
        <input type="hidden" name="__mode" value="post" />
        <input type="hidden" name="blog_id" value="<$mt:BlogID$>" />
        <input type="hidden" id="magic_token" name="magic_token" value="" />
        <div>
            <label for="entry-title">Title</label>
            <input id="entry-title" class="ti" name="title" />
        </div>
        <div>
            <label for="entry-title">Body</label>
            <textarea id="entry-body" class="ta" name="text" rows="15" cols="50"></textarea>
        </div>
        <input type="submit" accesskey="s" name="post" id="entry-submit" value="Submit" />
    </form>
<mt:Else>
    <p id="login_message"></p>
</mt:IfLoggedIn>

<!-- start footer --><hr />
<script type="text/javascript">
/* <![CDATA[ */
mtAttachEvent('usersignin', entry_create_loggedin);
mtAttachEvent('usersignin', mtUpdateSignInWidget);
mtUpdateSignInWidget();
/* ]]> */
</script>
</body>
</html>

Entry Response Template

The following template is a system template and will display a message to the user immediately after they have submitted their content to the system. The purpose of this template is give some indication to the user as to the status of their submission.

The template makes use of a special variable called entry_status. This variable is defined for you and will contain one of several values:

  • 1 - entry is unpublished and held for moderation
  • 2 - entry has been published

These values are used to control what message you display to the user depending upon their submission’s status.

Template Code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
<head>
    <title><$mt:BlogName encode_html="1"$></title>
    <meta http-equiv="Content-Type" content="text/html; charset=<$mt:PublishCharset$>" />
    <script type="text/javascript" src="<$mt:Link template="JavaScript"$>"></script>
</head>
<body>

<div id="signin-content">
    <a href="javascript:void(0)" onclick="return mtSignInOnClick('signin-content')">Sign In</a>
</div>

<h3>Navigation</h3>
<ul>
    <li><a href="<$mt:Link template="Homepage"$>">Home</a></li>
    <li><a href="<$mt:Link template="Create Entry"$>">Create Entry</a></li>
</ul>
<!-- end header --><hr />

<h1>Thank you for posting an entry.</h1>

<mt:If name="entry_status" eq="1">
    <p>Your entry has been received and held for approval by the blog owner.</p>
<mt:Else name="entry_status" eq="2">
    <p>Your entry has been posted.</p>
<mt:Else>
    <p>Your entry has been received.</p>
</mt:If>

<p>Return to the <a href="<$mt:BlogURL$>">blog's main index</a>.</p>

<!-- start footer --><hr />
<script type="text/javascript">
/* <![CDATA[ */
mtAttachEvent('usersignin', mtUpdateSignInWidget);
mtUpdateSignInWidget();
/* ]]> */
</script>
</body>
</html>
Back