Recent Changes - Search:

SimpleLog wiki

Installing SimpleLog

        MT(gs) users
        DreamHost users

Upgrading

Working with themes

How to

Troubleshooting

Development & resources

Helpers

This page is under active construction!

A list of the helpers available to you when building a theme. You should also see available post helper methods which can be used in views related to posts as well as available preferences.

Meta tags

Site.simple_meta_tag( name, val )

Create a meta tag with name name and value val. <%= Site.simple_meta_tag('test', 'yessir') %> will produce <meta name="test" content="yessir"/>

Site.default_meta_tags

Creates a default block of meta tags that most websites have. Includes content-type, author, description, dc.title and a start location link tag.

Site.icbm_meta_tag

Create a meta tag for GeoURL if the preference is set.

Site.esbn_meta_tag

Create a meta tag for an ESBN number if the preference is set.

Site.issn_meta_tag

Create a meta tag for an ISSN number if the preference is set.


Blocks

Site.list_tags_linked( tags [, div_id [, title [, archive_token [, separator]]]] )

Creates a list of all tags to which one or more post is assigned. The first argument of this method requires a collection of tags, which is available on nearly ever page of your site in the form of @tags. You should always pass @tags as the first argument. Example:
<%= Site.list_tags_linked(@tags) %>
Will produce:
<div id="tags">
    <b>Tags:</b> <a href="site.com/past/tags/test" title="View posts tagged with &quot;test&quot;">test</a>
</div>
You can pass different values to the optional arguments to customize this block. div_id will change the id of the div, title will alter the word placed before the list (you can pass an empty string to remove this altogether), archive_token should usually be your archive token preference (Preference.get_setting('archive_token')), and separator is the string to place between items in the list (default is ', ').

Site.list_authors_linked( authors [, div_id [, title [, archive_token [, separator]]]] )

Creates a list of all authors who have posted at least one active post. This first argument of this method requires a collection of authors, which is available on nearly every page of the site, assuming you enable the "Show authors" preference. Example:
<%= Site.list_authors_linked(@authors) %>
Will produce:
<div id="authors">
    <b>Authors:</b> <a href="site.com/past/authors/1" title="View all posts by Garrett Murray">Garrett Murray</a>
</div>
You can pass different values to the optional arguments to customize this block. div_id will change the id of the div, title will alter the word placed before the list (you can pass an empty string to remove this altogether), archive_token should usually be your archive token preference (Preference.get_setting('archive_token')), and separator is the string to place between items in the list (default is ', ').

Site.archive_structure_linked( posts [, start_header_level [, use_li ]] )

Builds a structured list of archive items for use in the main archives section of your site. posts is a collection of all active posts on the site. start_header_level is the HTML header level number to start with at the largest structural point (default is 3). Setting use_li to true will output unordered lists instead of a definition list. Example:
<%= Site.archives_structure_linked(@posts) %>
Will produce:
<dt>
    <dd><h3>2007</h3></dd>
    <dt>
        <dd><h4><a href="site.com/past/2007/1" title="January">January</a></h4></dd>
        <dd><a href="site.com/past/2007/1/post" title="Post">Post</a></dd>
    </dt>
</dt>

Site.get_posts( sql )

Grab and return posts using SQL. You can any SQL language to select posts and use them for any purpose on your site. Store the results in a variable and then loop through them to use them.
For instance, if you wish to have a list of the five recent posts in your sidebar, you could use the following code:
<% recent_posts = Site.get_posts('select * from posts order by created_at desc limit 5') -%>
<ul>
<% for rp in recent_posts -%>
    <li><%= rp.title %></li>
<% end -%>
</ul>


HTML/CSS/Javascript

Site.body_id

Returns a body ID for use in the HTML body tag. If you use this, people will have the option of overriding your CSS in their browsers.

Site.mint_tag

If your Mint location is set in preferences, this will return the standard Mint javascript code block.

Site.site_name_linked

Returns your site's name (as set in preferences) in an HTML link to the root of your site.

Site.rss_feed_link( [ name [, title ]] )

An HTML link to your posts RSS feed. Both name and title are optional and have simple default values. Override them to create a more customized link. The URL of this link is either the default RSS URL or the URL you specify in the RSS link location preference.

Site.comments_feed_link( [ name [, title ]] )

An HTML link to your comments RSS feed. Both name and title are optional and have simple default values. Override them to create a more customized link. The URL of this link is either the default comments RSS URL.

Site.delicious_info( [ wrap_in_p ] )

A simple way to tell users about your del.icio.us information. wrap_in_p is an optional boolean you can use to wrap the output in HTML p tags. The output of this is as follows:
Interesting links can be found at <a href="http://del.icio.us/username" title="del.icio.us">del.icio.us</a>
or by subscribing to my <a href="http://del.icio.us/rss/username" title="My del.icio.us feed">del.icio.us feed</a>

Site.link_to_page( link )

Creates an HTML link to a "static" page with the link link. For instance, if you have created a static page with the link "about", you could create an HTML link to it on any page like such:
<%= Site.link_to_page('about') %>

Site.permalink( post )

Creates an HTML link to a post. post must be a Post object from the database. This is most commonly used in post lists and such.


Various Outputted Texts

Site.copyright_range

When this site was copyrighted to present (if later). Initial copyright year is set in preferences. If the initial year is earlier than the current year, this will output YYYY-YYYY.

Site.powered_by_link

Outputs "Powered by SimpleLog", with the word SimpleLog linked to simplelog.net.

Site.primary_author_pronoun

Outputs "him" or "her" depending on the author gender set in preferences.


Global values

Site.full_url

Returns the full URL of the site, based on the value set in the domain preference. This is used throughout the site for accurate permalinks, navigation, and RSS structure.

Site.rss_url

The full RSS URL for the site, based on the Site.full_url value and the default RSS location or your value in preferences.

Site.comments_rss_url

The full comments RSS URL, based on the Site.full_url value and the default comments URL location.


Utilities for finding your current location

Site.current_location

Returns a string containing your current location in regards to theme files or, in the case of static pages, pages/your static page link name. You can use this to figure out where you are on the site in your theme views.
For instance, if you want to show a certain phrase on the site only when you're on the individual post archive page, you could do:
<% if Site.current_location == 'posts/show' -%>
    This is the individual page.
<% end -%>
For static pages, this will return 'pages/your_page_link'. See also: Site.page_is

Site.page_is( str )

Returns a boolean--is this page the same as the string passed in? Pass in the link assigned to the static page. Example:
<%= 'This is the about page.' if Site.page_is('about') %>
Use this to do various checks in your views for static pages.

Site.is_home_page

Returns a boolean--are we on the home page?

Site.is_archives

Returns a boolean--are we on an archive page?

Site.is_search

Returns a boolean--are we on a search results page (either quick or full)?

Site.is_static_page

Returns a boolean--are we on a static page?


Common Preference Booleans

Site.show_authors

Is the "Show Authors" preference enabled?

Site.comment_system_on

Is the comment system turned on?

Site.gravatars_on

Is the "Show Gravatars" preference enabled?

Site.allow_comment_subjects

Is the "Allow comment subjects" preference enabled?
Edit - History - Print - Recent Changes - Search
Page last modified on January 08, 2008, at 12:35 PM EST