Created
May 22, 2010 14:20
-
-
Save unruthless/410103 to your computer and use it in GitHub Desktop.
EE template: combined index and detail page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{!-- Segment_2 isn't blank, so show a blog post's detail page --} | |
{if segment_2 != ""} | |
<h1>Single Post</h1> | |
{exp:channel:entries channel="blog" url_title="{segment_2}"} | |
{!-- If segment_2 isn't a URL title for any existing blog post, redirect to the landing page --} | |
{if no_results} | |
{redirect="blog/index"} | |
{/if} | |
{!-- Otherwise display the blog post, with whatever markup you want --} | |
<article class="blog_post"> | |
<h1>{title}</h1> | |
{your_custom_blog_post_field_1} | |
{your_custom_blog_post_field_2} | |
{your_custom_blog_post_field_etc..} | |
</article> | |
{/exp:channel:entries} | |
{!-- Segment_2 is blank, so show the blog landing page --} | |
{if:else} | |
<h1>All Posts</h1> | |
{exp:channel:entries channel="blog" orderby="title" sort="asc"} | |
<article class="blog_post"> | |
<h2><a href="{url_title_path='blog'}">{title}</a></h2> | |
</article> | |
{/exp:channel:entries} | |
{/if} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment