Never been to DZone Snippets 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

« Newer Snippets
Older Snippets »
Showing 21-28 of 28 total

Categories For One Entry


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

List All Entries

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.
   1  
   2  <ul>
   3  {exp:weblog:entries weblog="weblog"}
   4  <li><a href="{url_title_path=template/view}">{title}</a></li>
   5  {/exp:weblog:entries}
   6  </ul>

List All Categories


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

Quick Cheat Sheet

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.

   1  
   2  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
   3  
   4  <html>
   5  <head>
   6  <title>Quick Cheat Sheet</title>
   7  
   8  <style type="text/css">
   9  <!-- 
  10  body{
  11  	background:#eee;
  12  	color:#333;
  13  	font: 11px Arial, sans-serif;
  14  } 
  15  table {
  16  	float:left;
  17  	margin:5px;
  18  	border:1px solid #ccc;
  19  }
  20  .heading{
  21  	background:#ddd;
  22  }
  23  -->
  24  </style>
  25  </head>
  26  <body>
  27  
  28  <table summary="Weblog IDs" cellpadding="5">
  29  <tr class="heading">
  30  <td><b>Full Weblog Name</b></td>
  31  <td><b>Short Name</b></td>
  32  <td><b>Weblog ID</b></td>
  33  </tr>
  34  {exp:query sql="SELECT weblog_id, blog_name, blog_title, blog_url FROM exp_weblogs ORDER BY blog_title"}
  35  <tr>
  36  <td>{blog_title}</td>
  37  <td>{blog_name}</td>
  38  <td>{weblog_id}</td>
  39  </tr>
  40  {/exp:query}
  41  </table>
  42  
  43  <table summary="Custom Field IDs" cellpadding="5">
  44  <tr class="heading">
  45  <td><b>Full Field Name</b></td>
  46  <td><b>Short Name</b></td>
  47  <td><b>Field Type</b></td>
  48  </tr>
  49  {exp:query sql="SELECT group_id, field_name, field_label, field_type FROM exp_weblog_fields ORDER BY field_name"}
  50  <tr>
  51  <td>{field_label}</td>
  52  <td>{field_name}</td>
  53  <td>{field_type}</td>
  54  </tr>
  55  {/exp:query}</table>
  56  
  57  <table summary="Category IDs" cellpadding="5">
  58  <tr class="heading">
  59  <td><b>Full Category Name</b></td>
  60  <td><b>Category ID</b></td>
  61  </tr>
  62  {exp:query sql="SELECT cat_name, cat_id, group_id FROM exp_categories ORDER BY group_id"}
  63  <tr>
  64  <td>{cat_name}</td>
  65  <td>{cat_id}</td>
  66  </tr>
  67  {/exp:query}</table>
  68  
  69  </body>
  70  </html>

List all Weblogs

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

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

Category Count

   1  
   2  {exp:query sql="SELECT count(exp_category_posts.entry_id) AS count,exp_category_posts.cat_id, exp_categories.cat_name
   3  FROM exp_categories, exp_category_posts WHERE exp_category_posts.cat_id = exp_categories.cat_id GROUP BY exp_categories.cat_name"}
   4  
   5  <a href="{path=weblog/view}C{cat_id}/">{cat_name}
   6  </a> ({count})
   7  
   8  {/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:

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

Related Entries

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

   1  
   2  <ul>
   3  {exp:weblog:related_entries weblog="caps" orderby="title" sort="asc"}
   4  <li><a href="{title_permalink="caps/view"}">{title}</a></li>
   5  {/exp:weblog:related_entries}
   6  </ul>

Category Header

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

Show the currently viewed category as a heading outside of the {weblog.entries} tag.
« Newer Snippets
Older Snippets »
Showing 21-28 of 28 total