A behind-the-scenes look at my EE code

Title image for A behind-the-scenes look at my EE code

My blog no longer uses ExpressionEngine, so this code doesn’t apply to this site.

I love using ExpressionEngine for my site, but to be honest, the documentation around it can be pretty confusing at times.

For instance, I spent well over an hour just finding out how to include a list of relevant categories for each post. So, here’s a pared-down version of what I’m using on my blog homepage. Take what you want of it, play around with it, and hopefully save yourself some searching around.

This code calls up the first 15 posts (ordered by descending date). It starts by displaying the post title as a link to the full post. It then checks to see if a summary has been written for the post. If so, it displays it; if not, the Word Limit Plus plug-in displays the first 100 words of the post, followed by a ‘Read more’ link.

The next section displays an information paragraph on each post, starting with the time and date of writing, a list of categories each post has been placed into, and (if any exist) a tally of how many comments each post has.

The final paginate section checks the number of posts. If there are more than 15 (or, in other words, more than will fill one page as specified above), then it displays links to go to further pages of entries.

{exp:weblog:entries weblog="my_weblog" orderby="date" sort="desc" limit="15"}
 
<p><a href="{title_permalink="site/post"}">{title}</a></p>
 
{if blog-summary}
{blog-summary}
{if:else}
{exp:word_limit_plus if_exceeds="100" stop_after="100" the_link="<a href='{title_permalink=site/post}'>Read the rest of this post&hellip;</a>"}
{blog-body}
{/exp:word_limit_plus}
{/if}
 
<p>Posted on {entry_date format='%j%S %F, %Y'} at {entry_date format='%g:%i%a'}<br />
Categories:{categories} <a href="{path=site/index}">{category_name}</a> {/categories}
{if allow_comments}{if comment_total > 0}&#8226; ({comment_total}) <a href="#">Comments</a>{/if}{/if}</p>
 
{/exp:weblog:entries}
 
{exp:weblog:entries weblog="my_weblog" orderby="date" sort="desc" limit="15"}
 
{paginate}
<span class="pagecount">Page {current_page} of {total_pages} pages</span>{pagination_links}
{/paginate}
 
{/exp:weblog:entries}

Leave a Comment





Rob Barrett Introduction