# Variables in Themes

Note: This is not a complete documentation of the theme variables - it only covers variables that can be used in the site header and in story templates.

## Introduction

Geeklog uses the template engine of the PHP Base Library (also known as PHPlib). This library allows the use of so-called variables in the template files. A variable is a word enclosed in curly brackets, like this: `{variable}`. When Geeklog creates a web page it will replace the variables in the template files with certain values. A variable can hold static text (i.e. it will alway be replaced with the same text), dynamic content (e.g. the number of comments to a story or the entire text of a story), or even the content of another template file (used for lists, for example).

Please note that not all variables are available in all template files. While the variable `{site_url}` (which holds the URL of your Geeklog site) is available in most template files, many variables are only available in one template file (e.g. the variable `{formatted_article}` is only available in the `article.thtml` template file). Geeklog will remove any variables which are not defined for the current template file (i.e. they will be replaced with an empty string). No error or warning messages will be created when you use an undefined variable.

## Site Header

The following variables are available in the site header, i.e. in the `header.thtml` template file:

Variable | Example | Description
--- | --- | ---
`site_url` | `http://www.example.com` | The URL of your Geeklog site (the exact same URL you specified in `$_CONF['site_url']` in the configuration.
`layout_url` | `http://www.example.com/layout/professional` | The URL of the layout folder of the user's current theme.
`page_title` | Geeklog Site - Another Nifty Geeklog Site | Holds either the site's name and slogan or the site name and the title of the current story.
`background_image` | `http://www.example.com/layout/ XSilver/images/bg.gif` | Points to a file named `bg.gif` in the `images` folder of the current theme, intended to be used as a background image.
`site_mail` | `admin@example.com` | Email address where people can contact the site's administrator. Because of the spam problem, it is recommended you don't actually use this on your site and provide a link to the Admin's email submission form instead: `{site_url}/profiles.php?uid=2` (where "2" is the user id of the person who will receive the email, usually the Admin user.
`site_name` | Geeklog Site | The name of your Geeklog site.
`site_slogan` | Another Nifty Geeklog Site | The slogan of your site.
`welcome_msg` | Welcome to Geeklog Site | A welcome message, followed by the user's name (for registered users).
`datetime` | Thursday, November 28 2002 @ 11:43 AM PST | The current date and time, formatted according to `$_CONF['date']`.
`site_logo` | `http://www.example.com/layout/ professional/images/logo.png` | Points to the logo image in the `images` directory of the current theme, intended to be used as the site's logo. This is usually a GIF image (`logo.gif`), but the image type can be overwritten by the theme (the Professional theme, for example, uses PNG images, and so the logo is a PNG file, `logo.png`, too).
`theme` | professional | Name of the current theme.
`charset` | iso-8859-1 | The character set for the current language file.
`lang_id` | `en-GB` | An ID representing the language used on your site. Ideally, this should be an ISO language/country code, e.g. 'en-GB' for British English. The value for this variable is the language shortcut used in the `$_CONF['languages']` array when multi-language support is enabled. Otherwise, it's derived from `$_CONF['locale']`, which involves some guesswork. In the latter case, this may also end up with a value like 'German' if your site is running on a non-Unix system (and which is not a valid ISO code).
`lang_attribute` | `lang="en-GB"` | An HTML lang attribute (including the value) to be used in your site header's HTML to indicate the language of your site or of the current page, e.g. like so:
    <html {lang_attribute}>
Please note that this variable is empty, i.e. not set, when the site's language ID does not appear to be a valid language code (see description of the `lang_id` variable above).
`feed_url` | `<link rel="alternate" type="application/rss+xml" hreflang="en-gb" href="http://www.example.com/backend/geeklog.rss" title="RSS Feed: Geeklog">` | Provides links to all the relevant feeds for the current page (depending on the "header link in topic" setting in the Feed Editor).
`rss_url` | `http://www.example.com/backend/geeklog.rdf` | The URL of your site's RSS feed (identical to `{rdf_file}`. This variable is also available in the site's `footer.thtml`. Deprecated: Use `{feed_url}` instead.
`rdf_file` | `http://www.example.com/backend/geeklog.rdf` | The URL of your site's RSS feed (identical to `{rss_url}`. This variable is also available in the site's `footer.thtml`. Deprecated: Use `{feed_url}` instead.
`rel_links` | `<link rel="home" href="http://www.example.com/" title="Home">` | Provides a set of predefined link tags, offering additional navigation links and relationship information.
`page_title_and_site_name` | `Geeklog Site - Another Nifty Geeklog Site` | As the name suggests, this variable provides the site name and the title for the current page. The order in which these two are provided depends on the current location on the website: On the site's frontpage, the site name comes first. On all the other pages, the current page title comes first.
`page_site_splitter` | `-` (a dash surrounded by spaces) | This variable comes in handy when creating your own page title, as it will be empty when the `{page_title}` variable is empty. Use in combination with `{page_title}` and `{site_name}` (see above).

## Stories

The following variables are available in the `storytext.thtml`, `storybodytext.thtml`, `featuredstorytext.thtml`, `featuredstorybodytext.thtml`, `archivestorytext.thtml`, and `archivestorybodytext.thtml` template files. These files are used to render stories for the index page as well as the content of the `{formatted_article}` variable in the `article/article.thtml` file (which is used to display a story on its own page).

Variable | Example | Description
--- | --- | ---
`site_url` | `http://www.example.com` | The URL of your Geeklog site (the exact same URL you specified in `$_CONF['site_url']` in the configuration.
`layout_url` | `http://www.example.com/layout/professional` | The URL of the layout folder of the user's current theme.
`story_date` | Tuesday, October 22 2002 @ 11:50 PM PDT | The date and time of the story, formatted according to the user's preferred date and time format.
`story_date_only` | 22-Oct | The date of the story, formatted using $_CONF['dateonly'].
`story_date_short` | 10/22/02 | The date of the story, formatted using $_CONF['shortdate'].
`lang_views` | Views | The word "Views" in the user's preferred language.
`story_hits` | 42 | Number of times the story was read.
`article_url` | http://www.geeklog.net/article.php?story=20021022234959146 | The full URL to the story on its own page (article.php). This will also reflect the correct URL when URL rewriting is activated.
`story_id` | 20021022234959146 | The ID of a story (can be used to build URLs, e.g. for a "link to this story" link).
`story_title` | Welcome to Geeklog! | The title of the story.
`story_introtext` | Welcome and let me be the first to congratulate you on installing Geeklog ... | When displayed on the index page, this variable contains The "intro text" part of a story. However, when displayed as an article on a single page, it contains both the intro text and the body text of the story.
`story_text_no_br` | Welcome and let me be the first to congratulate you on installing Geeklog ... | When displayed on the index page, this variable contains The "intro text" part of a story. However, when displayed as an article on a single page, it contains both the intro text and the body text of the story. The difference between `story_introtext` and `story_text_no_br` is that `story_introtext` inserts two HTML `<br>` tags between the intro and the body text whereas `story_text_no_br` does not do that (hence the name).
`story_introtext_only` | Welcome and let me be the first to congratulate you on installing Geeklog ... | As the name implies, this variable always contains only the story's intro text portion.
`story_bodytext_only` | (...) | This variable is only set when displaying the entire story. It contains only the body text portion of the story, if available.
`lang_todays_featured_article` | Today's Featured Article | The words "Today's Featured Article" in the user's preferred language. Only available when the story is the featured story.
`story_counter` | 1 | On the site's index page (`index.php`), this variable contains 1 for the first story, 2 for the second, etc. This is independent whether the first story is a featured story or not. The counter restarts with every new page (`index.php?page=2`, etc.). The variable contains 0 on the article page (`article.php`) and in story previews.

The following variables are only available when the story is displayed on the index page and the body text of the story is not empty:

Variable | Example | Description
--- | --- | ---
`lang_readmore` | read more | The words "read more" in the user's preferred language.
`lang_readmore_words` | words | The word "words" in the user's preferred language.
`readmore_words` | 62 | The number of words in the body text of the story.
`readmore_link` | `<a href="...">read more</a> (62 words)` | Link to the story on a separate page, including the number of word in the body text.
`start_readmore_anchortag` | `<a href=".../article.php ?story=20021022234959146">` | Opening tag for a link to the story on a separate page.
`end_readmore_anchortag` | `</a>` | Closing tag for a link to the story.
`read_more_class` | class="story-read-more" | This variable is empty when the body text is empty and contains the class attribute when the body text is not empty. Use the `story-read-more` class to change the layout of the "read more" link.
`email_icon` | (icon) | The email icon, linking to the form to send the article to a friend.
`email_story_url` | `http://.../profiles.php?sid=welcome` | The URL of the form to send the article to a friend.
`print_icon` | (icon) | The printer icon, linking to a "printer friendly" version of the story.
`recent_post_anchortag` | -- | When no comments have been posted yet, this variable contains just a link to the comment submission form (just like `{post_comment_link}`). When there are comments to the story, then this variable does not contain a link but instead contains the username of the person who posted the last comment as well as the date and time when that comment was posted.

The following variables are only available when comments on a story are enabled and when comments have been made to the story already:

Variable | Example | Description
--- | --- | ---
`comments_url` | `http://www.example.com/article.php ?story=20021022234959146#comments` | URL of the comments section (when a story is displayed on a separate page).
`comments_text` | 2 comments | The number of comments, followed by the word "comments" in the user's preferred language.
`comments_with_count` | 2 | The number of comments to the story (will always be 1 or greater). This string becomes a link as soon as there are comments available, pointing to `<a href=".../article.php?story=20021022234959146#comments">`
`comments_with_count` | 2 | The number of comments to story only (may be 0).
`lang_comments` | comments | The word "comments" in the user's preferred language.
`post_comment_link` | `<a href=".../comment.php ?sid=20021022234959146&pid=0 &type=article">Post a comment</a>` | Link to the comment submission form (using "Post a comment" in the user's preferred language as the link text).

The following variables are only available when `$_CONF['contributedbyline'] = 1;` in the configuration, i.e. when you allow the name of the story's author to be displayed:

Variable | Example | Description
--- | --- | ---
`lang_contributed_by` | Contributed by: | The text "Contributed by:" in the user's preferred language.
`contributedby_uid` | 7 | The user id of the story's author.
`contributedby_user` | Tony | The username (short name) of the story's author.
`contributedby_fullname` | Tony Bibbs | The full name of the story's author. If the user hasn't filled in his/her full name, the username is used instead.
`contributedby_author` | Tony Bibbs | The name of the story's author. If `$_CONF['show_fullname']` is enabled, it will contain the author's full name (if provided). Otherwise, it will contain the username.
`start_contributedby_anchortag` | `<a class="storybyline" href="http://www.example.com/ users.php?mode=profile&uid=7">` | Opening tag for a link to the story author's profile (empty for anonymous authors).
`end_contributedby_anchortag` | `</a>` | Closing tag for a link to the story author's profile (empty for anonymous authors).
`contributedby_url` | `http://www.example.com/ users.php?mode=profile&uid=7` | Link to the story author's profile (empty for anonymous authors).
`contributedby_photo` | `<img src=".../images/userphotos/Tony.gif" alt="Tony Bibbs">` | User photo of the story author, if provided (and user photos are enabled). For anonymous users, this will be an empty string, unless use of Gravatars is enabled or a default photo is configured.
`author_photo` | (see above) | Same as `{contributedby_photo}`
`camera_icon` | small camera icon and link to the author's user profile | Displays the camera icon (the same as in the Who's Online block) and links to the author's user profile if they have uploaded a user photo (never displayed for anonymous authors).

The following variables are only available if topic icons are enabled for the story and the user has not disabled topic icons in his/her display preferences:

Variable | Example | Description
--- | --- | ---
`story_anchortag_and_image` | `<a href="http://www.example.com/ index.php?topic=Geeklog"><img src="..." ...></a>` (shortened) | Topic icon for the story's topic, enclosed in a link to the site's index page, sorted by topic.
`story_anchortag_and_image_no_align` | `<a href="http://www.example.com/ index.php?topic=Geeklog"><img src="..." ...></a>` (shortened) | Same as `{story_anchortag_and_image}` but without the `align` attribute for the topic image.
`story_topic_image` | `<img src="http://www.example.com/ images/topics/topic_gl.gif" align="right" alt="Geeklog" title="Geeklog">` | Topic icon for the story.
`story_topic_image_no_align` | `<img src="http://www.example.com/ images/topics/topic_gl.gif" alt="Geeklog" title="Geeklog">` | Same as `{story_topic_image}` but without the `align` attribute for the topic image.
`story_topic_image_url` | `http://www.example.com/ images/topics/topic_gl.gif` | Just the URL of the topic icon.
`story_topic_id` | General | Id (internal name) of the topic, e.g. to be used in links.
`story_topic_name` | General News | Topic name (as seen on the Sections block).
`story_topic_url` | `<a href="http://www.example.com/ index.php?topic=General">` | URL to your site's index page, so that only stories with the story's topic are displayed.

The following variables are only available when the current user has the permissions to edit a story:

Variable | Example | Description
--- | --- | ---
`edit_link` | `<a href=".../admin/story.php ?mode=edit&sid=20021022234959146">edit</a>` | Link to open the story in the admin's story editor.
`edit_icon` | `<a href=".../admin/story.php ?mode=edit&sid=20021022234959146"><img src=".../images/edit.gif"></a>` | An icon linking to the admin's story editor to edit the story.
`edit_image` | `<img src=".../images/edit.gif">` | Only the `img` tag for the edit icon, without the link.
`edit_url` | `http://www.example.com/admin/story.php ?mode=edit&sid=20021022234959146` | URL to open the story in the admin's story editor
`lang_edit_text` | edit | The word "edit" in the user's preferred language.