We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Editing template for blog entries (nebie question)

How Do I?

acampbell's avatar
acampbell
3 posts
6 years ago
acampbell's avatar acampbell

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.

       
James Mathias's avatar
James Mathias
225 posts
6 years ago
James Mathias's avatar James Mathias

Hi, Can you post your template in full so we can help determine where it might be failing?

       
acampbell's avatar
acampbell
3 posts
6 years ago
acampbell's avatar acampbell

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 –}

{site_name}

{exp:channel:entries channel=”blog” orderby “entry_date” sort=”desc” limit=”10”}

{title}

{excerpt} {/exp:channel:entries}

       
James Mathias's avatar
James Mathias
225 posts
6 years ago
James Mathias's avatar James Mathias

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

       
acampbell's avatar
acampbell
3 posts
6 years ago
acampbell's avatar acampbell

Thank you very much for your help. Time pressures have prevented me from working further on this at present but I hope to be able to get back to it later, when I will try your useful suggestions. Thanks again.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.