|
SimpleLog wiki
Installing SimpleLog Upgrading Working with themes
How to
Troubleshooting Development & resources |
Themes /
HelpersThis 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
Create a meta tag with name name and value val. <%= Site.simple_meta_tag('test', 'yessir') %> will produce <meta name="test" content="yessir"/>
Creates a default block of meta tags that most websites have. Includes content-type, author, description, dc.title and a start location link tag.
Create a meta tag for GeoURL if the preference is set.
Create a meta tag for an ESBN number if the preference is set.
Create a meta tag for an ISSN number if the preference is set.
Blocks
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 "test"">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 ', ').
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 ', ').
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>
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
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.
If your Mint location is set in preferences, this will return the standard Mint javascript code block.
Returns your site's name (as set in preferences) in an HTML link to the root of your site.
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.
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.
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>
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') %>
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
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.
Outputs "Powered by SimpleLog", with the word SimpleLog linked to simplelog.net.
Outputs "him" or "her" depending on the author gender set in preferences.
Global values
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.
The full RSS URL for the site, based on the Site.full_url value and the default RSS location or your value in preferences.
The full comments RSS URL, based on the Site.full_url value and the default comments URL location.
Utilities for finding your current locationReturns 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
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.
Returns a boolean--are we on the home page?
Returns a boolean--are we on an archive page?
Returns a boolean--are we on a search results page (either quick or full)?
Returns a boolean--are we on a static page?
Common Preference Booleans
Is the "Show Authors" preference enabled?
Is the comment system turned on?
Is the "Show Gravatars" preference enabled?
Is the "Allow comment subjects" preference enabled?
|