Skip to content

Instantly share code, notes, and snippets.

@unruthless
Forked from anonymous/detail
Created May 22, 2010 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unruthless/410159 to your computer and use it in GitHub Desktop.
Save unruthless/410159 to your computer and use it in GitHub Desktop.
EE template: blog/detail
{!-- Segment_2 isn't blank, so show a blog post's details --}
{if segment_2 != ""}
{exp:channel:entries channel="blog" url_title="{segment_2}"}
{!-- If no results,
then segment_2 isn't a URL title for any existing blog post (typo? broken link?),
so redirect to the landing page --}
{if no_results}
{redirect="blog/index"}
{/if}
{!-- Otherwise display the blog post, with whatever markup you want --}
<div class="post">
<h2 class="postTitle"><a href="{path='blog/detail'}">{title}</a></h2>
<p>Posted {entry_date format='%m/%d'} by {screen_name}</p>
{summary}
{post_body}
</div> <!-- end post -->
{/exp:channel:entries}
{!-- Comment form should usually be outside exp:channel:entries, as it's a call to a separate module --}
{exp:comment:form channel="blog" preview="channel/preview"}
{if logged_out}
<label for="name">Name:</label> <input type="text" name="name" value="{name}" size="50" /><br />
<label for="email">Email:</label> <input type="text" name="email" value="{email}" size="50" /><br />
<label for="location">Location:</label> <input type="text" name="location" value="{location}" size="50" /><br />
<label for="url">URL:</label> <input type="text" name="url" value="{url}" size="50" /><br />
{/if}
<label for="comment">Comment:</label><br />
<textarea name="comment" cols="70" rows="10">{comment}</textarea>
<label><input type="checkbox" name="save_info" value="yes" {save_info} /> Remember my personal information</label><br />
<label><input type="checkbox" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?</label><br />
{if captcha}
<label for="captcha">Please enter the word you see in the image below:</label><br />
<p>{captcha}<br />
<input type="text" name="captcha" value="{captcha_word}" maxlength="20" /></p>
{/if}
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="preview" value="Preview" />
{/exp:comment:form}
<h3>Comments</h3>
{exp:comment:entries sort="asc" limit="20"}
<div class="comment">
{comment}
<p>By {name} on {comment_date format="%Y %m %d"}</p>
</div><!-- end comment -->
{/exp:comment:entries}
{!-- Segment_2 is blank, so get us out of here - redirect to the index template --}
{if:else}
{redirect="blog/index"}
{/if}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment