Never been to TextSnippets 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!)

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

Quick Cheat Sheet

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

<html>
<head>
<title>Quick Cheat Sheettitle>





"WeblogIDs" cellpadding="5">
"heading">

{exp:query sql="SELECTweblog_id,blog_name,blog_title,blog_urlFROMexp_weblogsORDERBYblog_title"}

{/exp:query}
Full Weblog Name Short Name Weblog ID
{blog_title} {blog_name} {weblog_id}
"CustomFieldIDs" cellpadding="5"> "heading"> {exp:query sql="SELECTgroup_id,field_name,field_label,field_typeFROMexp_weblog_fieldsORDERBYfield_name"} {/exp:query}
Full Field Name Short Name Field Type
{field_label} {field_name} {field_type}
"CategoryIDs" cellpadding="5"> "heading"> {exp:query sql="SELECTcat_name,cat_id,group_idFROMexp_categoriesORDERBYgroup_id"} {/exp:query}
Full Category Name Category ID
{cat_name} {cat_id}


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.
« Newer Snippets
Older Snippets »
Showing 21-25 of 25 total