Matt-SD
- Posts: 41
- Created: Fri Jan 14 02:40:02 2011 +0100
- Updated: Fri Jan 14 02:59:24 2011 +0100
- Permalink: (Tutorial) How the heck does Twig work?
PART 2: VARIABLES
One variable you will use often is the $site.url variable. In PHP this would be $site['url'] or $site->url whichever tickles your fancy. What that variable outputs is the URL of your Chyrp installation. For example, if your site was located at http://example.com/blog/ then that's exactly what $site.url would output.
<a href="$site.url">$site.name</a>
Here's a list of the variables you'll most likely use
- Theme:
- $theme.url = the theme's directory
- $theme.feeds = the RSS feeds associated with your blog in (uses a <link> tag)
- $theme.stylesheets = a <link> for every CSS file in the stylesheets directory
- $theme.javascripts = Same as above, but with javascripts
- Post (obvious explanations omitted):
- $post.feather
- $post.id
- $post.paginated = require the Pagination module.
- $post.paginated.prev_link = Previous page of the paginated entry
- $post.paginated.next_link
- $post.paginated.pages = Number of pages
- $post.created_at
- $post.url
- Text feather:
- $post.title
- $post.body
- Audio:
- $post.description
- $post.audio_player
- $post.dialogue = requires chat feather
- Link:
- $post.source = the link
- $post.name = name for the link
- $post.description
- Photo:
- ${ feathers['photo'].image_link(post, 434) } = outputs photo at a max width of 434
- $post.caption
- Quote:
- $post.quote
- $post.source = Who said it
- Video:
- ${ feathers['video'].embed_tag_for(post, 440) } = video player at 440 px wide
- $post.caption
- Flash: Don't know ANYTHING about this one
- Trigger: See this page: https://github.com/chyrp/chyrp/wiki/Triggers-%28List%29
- Modules: All the active modules
- Feathers: All the active feathers
- Title: The title of the current page or post
- Site: (I've excluded comments for the obvious ones)
- $site.url
- $site.name = Your blogs title
- $site.description
- $site.feed_url = The URL entered in the General Settings, Feed URL box
- $site.email
- $site.timezone
- $site.can_register = If users are allowed to register or not
- $site.comments_per_page
- Version: The version of Chyrp you are using
- Now: the current timestamp. Equivalent to PHP's time()
- Post: same as $_POST
- Get: same as $_GET
Of course, there a more, but these are the one's you'll use the most. If think there's a variable that isn't listed here, just ask on the IRC channel (#chyrp on irc.freenode.net)