Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Sasha http://nothing-less.net

Last Edited Entries

{exp:weblog:entries weblog="epguide" orderby="edit_date" limit="5"}
<h1>{title}</h1>
{/exp:weblog:entries}

Categories For One Entry

{categories backspace="4"}<a href="{path=weblog/index}">{category_name}</a> &gt; {/categories}

List All Entries

<ul>
{exp:weblog:entries weblog="weblog"}
<li><a href="{url_title_path=template/view}">{title}</a></li>
{/exp:weblog:entries}
</ul>


Content-sensitive, so putting this on a main index page will list all entries there are, on a category page all entries in that category, and on a date archive page all entries for that month.

List All Categories

{exp:weblog:categories weblog="name" show_empty="no" id="left_nav"}
<a href="{path="template"}">{category_name}</a>
{/exp:weblog:categories}

Quick Cheat Sheet

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Quick Cheat Sheet</title>

<style type="text/css">
<!-- 
body{
	background:#eee;
	color:#333;
	font: 11px Arial, sans-serif;
} 
table {
	float:left;
	margin:5px;
	border:1px solid #ccc;
}
.heading{
	background:#ddd;
}
-->
</style>
</head>
<body>

<table summary="Weblog IDs" cellpadding="5">
<tr class="heading">
<td><b>Full Weblog Name</b></td>
<td><b>Short Name</b></td>
<td><b>Weblog ID</b></td>
</tr>
{exp:query sql="SELECT weblog_id, blog_name, blog_title, blog_url FROM exp_weblogs ORDER BY blog_title"}
<tr>
<td>{blog_title}</td>
<td>{blog_name}</td>
<td>{weblog_id}</td>
</tr>
{/exp:query}
</table>

<table summary="Custom Field IDs" cellpadding="5">
<tr class="heading">
<td><b>Full Field Name</b></td>
<td><b>Short Name</b></td>
<td><b>Field Type</b></td>
</tr>
{exp:query sql="SELECT group_id, field_name, field_label, field_type FROM exp_weblog_fields ORDER BY field_name"}
<tr>
<td>{field_label}</td>
<td>{field_name}</td>
<td>{field_type}</td>
</tr>
{/exp:query}</table>

<table summary="Category IDs" cellpadding="5">
<tr class="heading">
<td><b>Full Category Name</b></td>
<td><b>Category ID</b></td>
</tr>
{exp:query sql="SELECT cat_name, cat_id, group_id FROM exp_categories ORDER BY group_id"}
<tr>
<td>{cat_name}</td>
<td>{cat_id}</td>
</tr>
{/exp:query}</table>

</body>
</html>


This EE code will create a quick Cheat Sheet that will list all your Weblogs with their short names and IDs, all your Custom Fields with their short names, and all your Categories with their IDs. This one page will save you having to look this up in the Admin panel constantly when editing/creating templates for your site. :)
Also posted at the EEWiki:
http://www.eewiki.com/wiki/Cheat_Sheet.

List all Weblogs

{exp:query sql="SELECT weblog_id, blog_name, blog_title, blog_url FROM exp_weblogs WHERE weblog_id != '100' ORDER BY blog_title"}
<li><a href="{blog_url}">{blog_title}</a></li>
{/exp:query}


Lists all weblogs in one installation and shows how to exclude one by example.

Category Count

{exp:query sql="SELECT count(exp_category_posts.entry_id) AS count,exp_category_posts.cat_id, exp_categories.cat_name
FROM exp_categories, exp_category_posts WHERE exp_category_posts.cat_id = exp_categories.cat_id GROUP BY exp_categories.cat_name"}

<a href="{path=weblog/view}C{cat_id}/">{cat_name}
</a> ({count})

{/exp:query}


Displays a list of categories with an entry count for each category. Alternatively, you can also use this query together with the {exp:weblog:categories} tag, making the query a lot smaller:

{exp:weblog:categories weblog="weblog1"}
<a href="{path=weblog/index}">{category_name}</a>
{exp:query sql="SELECT count(exp_category_posts.entry_id) AS count
 FROM exp_category_posts  WHERE exp_category_posts.cat_id =  {category_id} "}
({count} entries)
{/exp:query}
{/exp:weblog:categories}

Related Entries

<ul>
{exp:weblog:related_entries weblog="caps" orderby="title" sort="asc"}
<li><a href="{title_permalink="caps/view"}">{title}</a></li>
{/exp:weblog:related_entries}
</ul>


Lists all entries in the same category as the one you're currently viewing.

Category Header

{exp:weblog:category_heading  weblog="weblog1"}{category_name}{/exp:weblog:category_heading}

Show the currently viewed category as a heading outside of the {weblog.entries} tag.