Hullo everyone -
I’m trying to set up a blog by following the 10 Min Primer video. I got as far as pasting a sample entry. I then edited the blog template (index.html) as described in the video but I couldn’t see where to put the new code. I tried adding it to the end of the file but that didn’t make my text appear.
I’m probably missing something obvious but I seem to be stuck at this point. Grateful for any help.
This is the latest index.html I tried. I also had one that retained all the default stuff that had been generated but it’s lost now.
{layout='layouts/_blog-layout'}
{!– 404 Redirect ============ This is a listing page, it needs categories and pagination to work, but also needs to redirect if segment_2 is invalid . i.e. http://example.com/blog/nothing –} {if segment_2} {if segment_2 != 'category' AND segment_2 ~ '/^(?!P\d+).*/'} {redirect='404'} {/if} {/if}
{!– prevents 3rd ++ segments on non category listings –} {if segment_3} {if segment_2 != 'category'} {redirect='{segment_1}/{segment_2}’} {/if} {/if}
{!– prevents 4th ++ segments on category listings –} {if segment_4} {if segment_4 ~ '/^(?!P\d+).*/'} {redirect='{segment_1}/{segment_2}/{segment_3}’} {/if} {/if}
{!– prevents 5th ++ segments on paginated category listings –} {if segment_5} {redirect='{segment_1}/{segment_2}/{segment_3}/{segment_4}’} {/if}
{!– We use preload replace variables for in-template replacements for things like tag parameters that we might repeat here. That way if we change things down the road, we can just change it here instead of looking all over the template for them. –}
{!– page vars (prefix p_) –} {preload_replace:p_title='My Blog'} {preload_replace:p_description='A blog about things, things I like and things I do.'} {preload_replace:p_url='blog'} {preload_replace:p_url_entry='entry'} {!– channel vars (prefix ch_) –} {preload_replace:ch='blog'} {preload_replace:ch_disable='category_fields|member_data'}
{!– every template using the blog layout will set these which lets us use shared markup with customizable details. –} :` {!– layout vars, channel/page related –} {layout:set name='ch' value='{ch}’} {layout:set name='p_url' value='{p_url}’} {layout:set name='p_title' value='{p_title}’} {!– layout vars, static –} {layout:set name='title' value='{p_title}{gv_sep}’} {layout:set name='description' value='{p_description}’} {!– OpenGraph meta output –} {layout:set name='og_title' value='{p_title}’} {layout:set name='og_url'}{path='{p_url}’}{/layout:set} {layout:set name='og_description' value='{p_description}’}
{!– Everything below is the “meat” of the template. We’ll use tags to output content, which will populate the layout:contents of the layouts/_blog-layout layout –}
{exp:channel:entries channel=”blog” orderby “entry_date” sort=”desc” limit=”10”}
{excerpt} {/exp:channel:entries}
It looks like you might be using the Default Theme. The video was built around doing a blog from scratch, and the Default Theme is built so that you don’t have to create something from scratch, but can instead just start writing. The two tools are kind of opposites of each other.
And since the video primer doesn’t go over how to incorporate your blog into the Default theme, it can be difficult to do so.
I would check the following;
Make sure that the orderby
parameter has an = sign like orderby='entry_date'
Also double check that your Channel’s shortname is in fact blog, and that you have a field called excerpt in that channel. The rest of the code in that template except the layout declarations will have no affect.
You can also try making the whole template just this
{site_name}
{exp:channel:entries channel='blog' orderby='entry_date' sort='desc' limit='10'}
{title}
{excerpt}
{/exp:channel:entries}
And see if that works, if not there is likely an issue with the field name or channel shortname
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.