This project has moved. For the latest updates, please go here.

Data Extension Commands

Data is a built-in Chalk extension, similar to Macros, which enables quick and easy access to additional Graffiti data.

To use the data extension commands, just type $data and one of the methods listed below.

Categories()
Retrieves a list of all top level categories sorted alphabetically.

Featured()
Retrieves the site's featured post. It will return null if no Post is found. You may want to use this with $macros.IsNull.

Example:
#set($featuredPost = $data.Featured())

#if($macros.IsNull($featuredPost))

<h1>No featured post was found</h1>

#else

<h1>Featured: <a href="$featuredPost.Url">$featuredPost.Title</a></h1>

#end
Featured(int categoryId)
Retrieves the featured post for the category id. Just like Featured(), this method may return a null value. See example above.

GetPost(int id)
Retrieves the specified post.

PopularPosts(int numberOfPosts)
Retrieves a list of the sites most popular (by views) posts.

PopularPosts(int numberOfPosts, int categoryId)
Retrieves a list of the sites most popular (by views) posts for the category id.

Query(IDictionary parameters)
Allows you to query for specific content. At this time only posts are supported.

Example: Return the top 5 posts, regardless of category and order by Views Descending:
<ul>
    #foreach($px in $data.Query(”%{top='5', orderby='Views DESC'}”))
    <li>    <a href=”$px.Url”>$px.Title</a></li>
    #end
</ul>
Parameter Info:
  • orderby – This is also optional. For post it will default to Published DESC.
  • top – Return the first N items
  • pageIndex – return page N of the set. Index is 1 based.
  • pageSize – number of items to return per page. If pageIndex exists, this will default to 10.
  • IsDeleted – defaults to false. By default, delete items will be excluded.
  • IsPublished – by default, only published posts will be returned.
  • [ColumnName] – You can also optionally specify any other column name to filter by. At this time, only exact/equal matches are supported.
RecentComments(int numberOfComments)
Retrieves a list of recent comments.

RecentComments(int numberOfComments, int categoryId)
Retrieves a list of recent comments from the category id.

RecentPosts(int numberOfPosts)
Retrieves the most recent “numberOfPosts”

RecentPosts(int numberOfPosts, int categoryId)
Retrieves a list of recent posts from the category id.

Tags(int min, int max)
Retrieves a list of tags. Min is the minimum number of posts a tag must contain. Max is the maximum number of tags to return.

Developer Tip: You can use the Data helpers above when you are writing Widgets, Chalk extensions, and Plug-ins for Graffiti. The object is found at Graffiti.Core.Data.

Last edited Mar 31, 2010 at 5:16 AM by jkillebrew, version 1

Comments

No comments yet.