Home > The Template System > Process Templates > The Userpost Template

Table of Contents

DotAdmin User Guide

The Userpost Template

The userpost site process (/content/userpost/) allows users make new posts to dotAdmin forums, or edit their existing posts.

Forum userpost initial page output
Forum userpost initial page output.

Forum userpost successful “thankyou” output
Forum userpost successful “thankyou” output.

The forum template is broken into four main blocks, one or more of which can be displayed at each stage of the process.

BLOCK {edit_form}

When a user start creating a new post, opens a post for editing, or previews a post during the edit process, BLOCK {edit_form} is displayed containing the edit form and the current post content.

<form method="post" action="/content/userpost">
<table cellspacing="5" cellpadding="0" border="0">
 <!-- IF {forum} -->
 <input type="hidden" name="forum" value="{forum}" />
 <!-- /IF {forum} -->
 <!-- IF {parent} -->
 <input type="hidden" name="parent" value="{parent}" />
 <!-- /IF {parent} -->
 <!-- IF {edit} -->
 <input type="hidden" name="edit" value="{edit}" />
 <!-- /IF {edit} -->
 <tr>
  <td valign="top"><p><label for="title">Title:</label></p></td>
  <td valign="top">
   <input type="text" name="title" id="title" value="{escaped title}">
  </td>
 </tr>
 <tr>
  <td valign="top"><p><label for="content">Content:</label></p></td>
  <td>
   <textarea name="content" id="content" rows="30" cols="80">
    {escaped content}
   </textarea></td>
 </tr>
 <!-- BLOCK {watched} -->
 <tr>
  <td valign="top"></td>
  <td><p><label for="watch">
   <!-- IF {yes} -->
    <input type="checkbox" name="watch" value="yes" checked="checked" />
   <!-- /IF {yes} -->
   <!-- ELSE -->
    <input type="checkbox" name="watch" value="yes" />
   <!-- /ELSE -->
    Watch this thread</label></p>
  </td>
 </tr>
 <!-- /BLOCK {watched} -->
 <tr>
  <td>&nbsp;</td>
  <td><input type="submit" name="action" value="preview">
   <input type="submit" name="action" value="save"></td>
 </tr>
</table>
</form>

Typical edit_form BLOCK template code.

Below is a list of all placeholders used in the edit_form BLOCK of the userpost template:

Placeholder Output
{forum} If this is post is a new thread, this element is displayed containing the unique ID of the forum to be posted to.
{parent} If this is a new post in reply to an existing thread, this element is displayed containing the unique ID of the post it replies to.
{edit} If an existing post is being edited, this element is displayed containing the unique ID of the post being edited.
{title} The title of the post being edited. Usually returned to the template using the escaped placeholder qualifier, as the value of an <input> field.
{content} The content of the post being edited. Usually returned to the template using the escaped placeholder qualifier, and the content of a <textarea>.
{name} Inside BLOCK {missing_fields}, the name of the required field which is missing.
BLOCK {watched} This element is displayed if the user is logged in, and contains the user's current “watching” status on this thread.
IF {yes} Inside BLOCK {watched}, this element is displayed if the user is logged in, and is “watching” this thread (i.e. they recieve email notification of new posts).

BLOCK {preview}

The user can preview his post by hitting the “Preview” button on the edit form. The preview will be displayed in this block.

 <table width="80%" cellspacing="0" cellpadding="5" border="1">
 <!-- IF {title} -->
 <tr>
  <td valign="top"><p><b>{title}</b></p></td>
 </tr>
 <!-- /IF {title} -->
 <tr>
  <td valign="top">{literal display_content}</td>
 </tr>
</table>

Typical preview BLOCK template code.

Below is a list of all placeholders used in the preview BLOCK of the userpost template:

Placeholder Output
{title} The title of the post
{display_content} The content of the post converted to HTML, escaped for HTML display, with special forum markup parsed and converted to HTML. Usually returned to the template using the literal placeholder qualifier.

BLOCK {save}

When a user post has been sucessfully posted or edited, BLOCK {save} is displayed containing the confirmation message.

CODE SAMPLE HERE.

Note - this element of the template needs fixing

Form template “thankyou” message.

Below is a list of all placeholders used in the save BLOCK of the userpost template:

Placeholder Output
{id} The unique ID of the current thread.
{title} The title of the post.
IF {accepted} This element is displayed if a new post is accepted and added to the forum.
IF {edited} This element is displayed if user edits to a post are sucessfully saved.
IF {screened} This element is displayed if a new post is accepted, but requires screening before publication. This feature is not yet implemented in the dotAdmin forum system.
IF {failed} This element is displayed if saving the post fails for any other reason. The element is provided in order that the userpost function can create output if a non-specified error occurs during saving.

BLOCK {error}

This block will be displayed if a user post edit session fails. An edit can fail for one or more of the following resons:

New thread with a missing title
New threads require a title. If a user attempts to save a new thread without a title, or attempts to save edits to the first post in a thread with the title empty, this error is generated.
Edit denied
This error occurs when a user attempts to edit a post which they are not permitted to edit.
Posting denied
This error occurs when a user attempts to make a new post to a thread where they cannot post.
Login required
This error occurs if the user is not logged in, and attempts to post to a thread which only accepts logged in users.

To simply display the two main errors, we could use the following code:

CODE SAMPLE HERE

Extended error output, detailing which fields were missing from the form submission.

Below is a list of all placeholders used in the error BLOCK of the userpost template:

Placeholder Output
{id} The unique ID of the current thread.
IF {no_title} This element is displayed if a user attempts to save a new thread without a title, or attempts to save edits to the first post in a thread with the title empty.
IF {edit_denied} This element is displayed if a user attempts to edit a post which they are not permitted to edit.
IF {posting_denied} This element is displayed if a user attempts to make a new post to a thread where they cannot post.
IF {login} This element is displayed if the user is not logged in, and attempts to post to a thread which only accepts logged in users. The conditional usually contains a login form within it