1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <title>Geeklog Documentation - Variables in Themes</title>
5 <link rel="stylesheet" type="text/css" href="../docstyle.css" title="Dev Stylesheet">
9 <p><a href="http://www.geeklog.net/" style="background:transparent"><img src="../images/newlogo.gif" alt="Geeklog" width="243" height="90"></a></p>
10 <div class="menu"><a href="index.html">Geeklog Documentation</a> - Variables in Themes</div>
12 <h1>Variables in Themes</h1>
14 <p><strong>Note:</strong> This is not a complete documentation of the theme
15 variables - it only covers variables that can be used in the site header and
16 in story templates.</p>
20 <p>Geeklog uses the template engine of the <a href="http://phplib.sf.net/">PHP
21 Base Library</a> (also known as PHPlib). This library allows the use of
22 so-called variables in the template files. A variable is a word enclosed in
23 curly brackets, like this: <code>{variable}</code>. When Geeklog creates a web
24 page it will replace the variables in the template files with certain values.
25 A variable can hold static text (i.e. it will alway be replaced with the same
26 text), dynamic content (e.g. the number of comments to a story or the entire
27 text of a story), or even the content of another template file (used for lists,
30 <p>Please note that not all variables are available in all template files.
31 While the variable <code>{site_url}</code> (which holds the URL of your Geeklog
32 site) is available in most template files, many variables are only available
33 in one template file (e.g. the variable <code>{formatted_article}</code> is only
34 available in the <tt>article.thtml</tt> template file). Geeklog will remove any
35 variables which are not defined for the current template file (i.e. they will
36 be replaced with an empty string). No error or warning messages will be
37 created when you use an undefined variable.</p>
40 <h2><a name="site-header">Site Header</a></h2>
42 <p>The following variables are available in the site header, i.e. in the
43 <tt>header.thtml</tt> template file:</p>
45 <table border="1" width="100%" cellpadding="2">
46 <tr><th style="width:8%">Variable</th>
47 <th style="width:29%">Example</th>
48 <th style="width:63%">Description</th></tr>
49 <tr><td><code>site_url</code></td>
50 <td><tt>http://www.example.com</tt></td>
51 <td>The URL of your Geeklog site (the exact same URL you specified in
52 <code>$_CONF['site_url']</code> in the configuration.</td></tr>
53 <tr><td><code>layout_url</code></td>
54 <td><tt>http://www.example.com/layout/professional</tt></td>
55 <td>The URL of the layout folder of the user's current theme.</td></tr>
56 <tr><td><code>page_title</code></td>
57 <td>Geeklog Site - Another Nifty Geeklog Site</td>
58 <td>Holds either the site's name and slogan or the site name and the title
59 of the current story.</td></tr>
60 <tr><td><code>background_image</code></td>
61 <td><tt>http://www.example.com/layout/<br>XSilver/images/bg.gif</tt></td>
62 <td>Points to a file named <tt>bg.gif</tt> in the <tt>images</tt> folder of
63 the current theme, intended to be used as a background image.</td></tr>
64 <tr><td><code>site_mail</code></td>
65 <td><tt>admin@example.com</tt></td>
66 <td>Email address where people can contact the site's administrator.
67 Because of the spam problem, it is recommended you don't actually use
68 this on your site and provide a link to the Admin's email submission
69 form instead: <tt>{site_url}/profiles.php?uid=2</tt> (where "2" is the
70 user id of the person who will receive the email, usually the Admin
72 <tr><td><code>site_name</code></td>
74 <td>The name of your Geeklog site.</td></tr>
75 <tr><td><code>site_slogan</code></td>
76 <td>Another Nifty Geeklog Site</td>
77 <td>The slogan of your site.</td></tr>
78 <tr><td><code>welcome_msg</code></td>
79 <td>Welcome to Geeklog Site</td>
80 <td>A welcome message, followed by the user's name (for registered
82 <tr><td><code>datetime</code></td>
83 <td>Thursday, November 28 2002 @ 11:43 AM PST</td>
84 <td>The current date and time, formatted according to
85 <code>$_CONF['date']</code>.</td></tr>
86 <tr><td><code>site_logo</code></td>
87 <td><tt>http://www.example.com/layout/<br>professional/images/logo.png</tt></td>
88 <td>Points to the logo image in the <tt>images</tt> directory of the
89 current theme, intended to be used as the site's logo. This is usually
90 a GIF image (<tt>logo.gif</tt>), but the image type can be overwritten
91 by the theme (the Professional theme, for example, uses PNG images, and
92 so the logo is a PNG file, <tt>logo.png</tt>, too).</td></tr>
93 <tr><td><code>css_url</code></td>
94 <td><tt>http://www.example.com/layout/<br>professional/style.css</tt></td>
95 <td>Points to the style sheet of the current theme.</td></tr>
96 <tr><td><code>theme</code></td>
98 <td>Name of the current theme.</td></tr>
99 <tr><td><code>charset</code></td>
101 <td>The character set for the current language file.</td></tr>
102 <tr><td><code>lang_id</code></td>
104 <td>An ID representing the language used on your site. Ideally, this should
105 be an ISO language/country code, e.g. 'en-GB' for British English. The
106 value for this variable is the language shortcut used in the
107 <code>$_CONF['languages']</code> array when multi-language support is
108 enabled. Otherwise, it's derived from <code>$_CONF['locale']</code>,
109 which involves some guesswork. In the latter case, this may also end
110 up with a value like 'German' if your site is running on a non-Unix
111 system (and which is not a valid ISO code).</td></tr>
112 <tr><td><code>lang_attribute</code></td>
113 <td><tt>lang="en-GB"</tt>
114 <td>An <a href="http://www.w3.org/TR/html4/struct/dirlang.html#adef-lang">HTML lang attribute</a> (including the value) to be used in your site
115 header's HTML to indicate the language of your site or of the current
116 page, e.g. like so: <pre><html {lang_attribute}></pre>
117 Please note that this variable is <em>empty</em>, i.e. not set, when
118 the site's language ID does not appear to be a <a href="http://www.w3.org/TR/html4/struct/dirlang.html#langcodes">valid language code</a> (see
119 description of the <code>lang_id</code> variable above).</td></tr>
120 <tr><td><code>feed_url</code></td>
121 <td><tt><link rel="alternate" type="application/rss+xml" hreflang="en-gb" href="http://www.example.com/backend/geeklog.rss" title="RSS Feed: Geeklog"></tt></td>
122 <td>Provides links to all the relevant feeds for the current page
123 (depending on the "header link in topic" setting in the Feed Editor).</td></tr>
124 <tr><td><code>rss_url</code></td>
125 <td><tt>http://www.example.com/backend/geeklog.rdf</tt></td>
126 <td>The URL of your site's RSS feed (identical to <code>{rdf_file}</code>.
127 This variable is also available in the site's <tt>footer.thtml</tt>.
128 <strong>Deprecated:</strong> Use <code>{feed_url}</code> instead.</td></tr>
129 <tr><td><code>rdf_file</code></td>
130 <td><tt>http://www.example.com/backend/geeklog.rdf</tt></td>
131 <td>The URL of your site's RSS feed (identical to <code>{rss_url}</code>.
132 This variable is also available in the site's <tt>footer.thtml</tt>.
133 <strong>Deprecated:</strong> Use <code>{feed_url}</code> instead.</td></tr>
134 <tr><td><code>rel_links</code></td>
135 <td><tt><link rel="home" href="http://www.example.com/" title="Home"></tt></td>
136 <td>Provides a set of predefined <a href="http://www.w3.org/TR/html4/struct/links.html#edef-LINK">link tags</a>, offering additional navigation links and
137 relationship information.</td></tr>
138 <tr><td><code>page_title_and_site_name</code></td>
139 <td><tt>Geeklog Site - Another Nifty Geeklog Site</tt></td>
140 <td>As the name suggests, this variable provides the site name and the title
141 for the current page. The order in which these two are provided depends
142 on the current location on the website: On the site's frontpage, the
143 site name comes first. On all the other pages, the current page title
144 comes first.</td></tr>
145 <tr><td><code>page_site_splitter</code></td>
146 <td><tt> - </tt> (a dash surrounded by spaces)</td>
147 <td>This variable comes in handy when creating your own page title, as it
148 will be empty when the <code>{page_title}</code> variable is empty. Use
149 in combination with <code>{page_title}</code> and
150 <code>{site_name}</code> (see above).</td></tr>
154 <h2><a name="story">Stories</a></h2>
156 <p>The following variables are available in the <tt>storytext.thtml</tt>,
157 <tt>storybodytext.thtml</tt>, <tt>featuredstorytext.thtml</tt>,
158 <tt>featuredstorybodytext.thtml</tt>, <tt>archivestorytext.thtml</tt>, and
159 <tt>archivestorybodytext.thtml</tt> template files. These files are used to
160 render stories for the index page as well as the content of the
161 <code>{formatted_article}</code> variable in the <tt>article/article.thtml</tt>
162 file (which is used to display a story on its own page).</p>
164 <table border="1" width="100%" cellpadding="2">
165 <tr><th style="width:8%">Variable</th>
166 <th style="width:29%">Example</th>
167 <th style="width:63%">Description</th></tr>
168 <tr><td><code>site_url</code></td>
169 <td><tt>http://www.example.com</tt></td>
170 <td>The URL of your Geeklog site (the exact same URL you specified in
171 <code>$_CONF['site_url']</code> in the configuration.</td></tr>
172 <tr><td><code>layout_url</code></td>
173 <td><tt>http://www.example.com/layout/professional</tt></td>
174 <td>The URL of the layout folder of the user's current theme.</td></tr>
175 <tr><td><code>story_date</code></td>
176 <td>Tuesday, October 22 2002 @ 11:50 PM PDT</td>
177 <td>The date and time of the story, formatted according to the user's
178 preferred date and time format.</td></tr>
179 <tr><td><code>story_date_only</code></td>
181 <td>The date of the story, formatted using
182 $_CONF['<a href="config.html#desc_dateonly">dateonly</a>'].</td></tr>
183 <tr><td><code>story_date_short</code></td>
185 <td>The date of the story, formatted using
186 $_CONF['<a href="config.html#desc_shortdate">shortdate</a>'].</td></tr>
187 <tr><td><code>lang_views</code></td>
189 <td>The word "Views" in the user's preferred language.</td></tr>
190 <tr><td><code>story_hits</code></td>
192 <td>Number of times the story was read.</td></tr>
193 <tr><td><code>article_url</code></td>
194 <td>http://www.geeklog.net/article.php?story=20021022234959146</td>
195 <td>The full URL to the story on its own page (article.php). This will also
196 reflect the correct URL when URL rewriting is activated.</td></tr>
197 <tr><td><code>story_id</code></td>
198 <td>20021022234959146</td>
199 <td>The ID of a story (can be used to build URLs, e.g. for a "link to this
200 story" link).</td></tr>
201 <tr><td><code>story_title</code></td>
202 <td>Welcome to Geeklog!</td>
203 <td>The title of the story.</td></tr>
204 <tr><td><code>story_introtext</code></td>
205 <td>Welcome and let me be the first to congratulate you on installing Geeklog ...</td>
206 <td>When displayed on the index page, this variable contains The "intro
207 text" part of a story. However, when displayed as an article on a
208 single page, it contains <em>both</em> the intro text <em>and</em> the
209 body text of the story.</td></tr>
210 <tr><td><code>story_text_no_br</code></td>
211 <td>Welcome and let me be the first to congratulate you on installing Geeklog ...</td>
212 <td>When displayed on the index page, this variable contains The "intro
213 text" part of a story. However, when displayed as an article on a
214 single page, it contains <em>both</em> the intro text <em>and</em> the
215 body text of the story. The difference between <tt>story_introtext</tt>
216 and <tt>story_text_no_br</tt> is that <tt>story_introtext</tt> inserts
217 two HTML <tt><br></tt> tags between the intro and the body text
218 whereas <tt>story_text_no_br</tt> does not do that (hence the name).</td></tr>
219 <tr><td><code>story_introtext_only</code></td>
220 <td>Welcome and let me be the first to congratulate you on installing Geeklog ...</td>
221 <td>As the name implies, this variable <em>always</em> contains
222 <em>only</em> the story's intro text portion.</td>
223 <tr><td><code>story_bodytext_only</code></td>
224 <td><i>(...)</i></td>
225 <td>This variable is only set when displaying the entire story. It contains
226 <em>only</em> the body text portion of the story, if
228 <tr><td><code>lang_todays_featured_article</code></td>
229 <td>Today's Featured Article</td>
230 <td>The words "Today's Featured Article" in the user's preferred language.
231 <strong>Only available when the story is the featured story.</strong></td></tr>
232 <tr><td><code>story_counter</code></td>
234 <td>On the site's index page (<tt>index.php</tt>), this variable contains
235 1 for the first story, 2 for the second, etc. This is independent
236 whether the first story is a featured story or not. The counter restarts
237 with every new page (<tt>index.php?page=2</tt>, etc.).<br>
238 The variable contains 0 on the article page (<tt>article.php</tt>) and
239 in story previews.</td></tr>
242 <p>The <a name="readmore">following variables</a> are only available when the
243 story is displayed on the index page <em>and</em> the body text of the story is
244 <em>not</em> empty:</p>
246 <table border="1" width="100%" cellpadding="2">
247 <tr><th style="width:8%">Variable</th>
248 <th style="width:29%">Example</th>
249 <th style="width:63%">Description</th></tr>
250 <tr><td><code>lang_readmore</code></td>
252 <td>The words "read more" in the user's preferred language.</td></tr>
253 <tr><td><code>lang_readmore_words</code></td>
255 <td>The word "words" in the user's preferred language.</td></tr>
256 <tr><td><code>readmore_words</code></td>
258 <td>The number of words in the body text of the story.</td></tr>
259 <tr><td><code>readmore_link</code></td>
260 <td><code><a href="...">read more</a> (62 words)</code></td>
261 <td>Link to the story on a separate page, including the number of word in
262 the body text.</td></tr>
263 <tr><td><code>start_readmore_anchortag</code></td>
264 <td><code><a href=".../article.php<br>?story=20021022234959146"></code></td>
265 <td>Opening tag for a link to the story on a separate page.</td></tr>
266 <tr><td><code>end_readmore_anchortag</code></td>
267 <td><code></a></code></td>
268 <td>Closing tag for a link to the story.</td></tr>
269 <tr><td><code>read_more_class</code></td>
270 <tr><td><code>email_icon</code></td>
271 <td>class="story-read-more"</td>
272 <td>This variable is empty when the body text is empty and contains the
273 class attribute when the body text is not empty. Use the
274 <code>story-read-more</code> class to change the layout of the "read
275 more" link.</td></tr>
276 <tr><td><code>print_icon</code></td>
278 <td>The printer icon, linking to a "printer friendly" version of the story.</td></tr>
279 <tr><td><code>recent_post_anchortag</code></td>
281 <td>When no comments have been posted yet, this variable contains just a
282 link to the comment submission form (just like
283 <code>{post_comment_link}</code>). When there are comments to the story,
284 then this variable does <em>not</em> contain a link but instead
285 contains the user name of the person who posted the last comment as well
286 as the date and time when that comment was posted.</td></tr>
289 <p>The following variables are only available when comments on a story are
290 enabled and when comments have been made to the story already:</p>
292 <table border="1" width="100%" cellpadding="2">
293 <tr><th style="width:8%">Variable</th>
294 <th style="width:29%">Example</th>
295 <th style="width:63%">Description</th></tr>
296 <tr><td><code>comments_url</code></td>
297 <td><tt>http://www.example.com/article.php<br>?story=20021022234959146#comments</tt></td>
298 <td>URL of the comments section (when a story is displayed on a separate
300 <tr><td><code>comments_text</code></td>
302 <td>The number of comments, followed by the word "comments" in the user's
303 preferred language.</td></tr>
304 <tr><td><code>comments_with_count</code></td>
306 <td>The number of comments to the story (will always be 1 or greater). <br>This string becomes a link as soon as there are comments available, pointing to <code><a href=".../article.php?story=20021022234959146#comments"></code></td></tr>
307 <tr><td><code>lang_comments</code></td>
309 <td>The word "comments" in the user's preferred language.</td></tr>
310 <tr><td><code>post_comment_link</code></td>
311 <td><code><a href=".../comment.php<br>?sid=20021022234959146&pid=0<br>&type=article">Post a comment</a></code></td>
312 <td>Link to the comment submission form (using "Post a comment" in the
313 user's preferred language as the link text).</td></tr>
316 <p>The following variables are only available when
317 <code>$_CONF['contributedbyline'] = 1;</code> in the configuration, i.e.
318 when you allow the name of the story's author to be displayed:</p>
320 <table border="1" width="100%" cellpadding="2">
321 <tr><th style="width:8%">Variable</th>
322 <th style="width:29%">Example</th>
323 <th style="width:63%">Description</th></tr>
324 <tr><td><code>lang_contributed_by</code></td>
325 <td>Contributed by:</td>
326 <td>The text "Contributed by:" in the user's preferred language.</td></tr>
327 <tr><td><code>contributedby_uid</code></td>
329 <td>The user id of the story's author.</td></tr>
330 <tr><td><code>contributedby_user</code></td>
332 <td>The user name (short name) of the story's author.</td></tr>
333 <tr><td><code>contributedby_fullname</code></td>
335 <td>The full name of the story's author. If the user hasn't filled in
336 his/her full name, the user name is used instead.</td></tr>
337 <tr><td><code>contributedby_author</code></td>
339 <td>The name of the story's author. If <code>$_CONF['show_fullname']</code>
340 is enabled, it will contain the author's full name (if provided).
341 Otherwise, it will contain the user name.</td></tr>
342 <tr><td><code>start_contributedby_anchortag</code></td>
343 <td><code><a class="storybyline" href="http://www.example.com/<br>users.php?mode=profile&uid=7"></code></td>
344 <td>Opening tag for a link to the story author's profile (empty for
345 anonymous authors).</td></tr>
346 <tr><td><code>end_contributedby_anchortag</code></td>
347 <td><code></a></code></td>
348 <td>Closing tag for a link to the story author's profile (empty for
349 anonymous authors).</td></tr>
350 <tr><td><code>contributedby_url</code></td>
351 <td><tt>http://www.example.com/<br>users.php?mode=profile&uid=7</tt></td>
352 <td>Link to the story author's profile (empty for anonymous authors).</td></tr>
353 <tr><td><code>contributedby_photo</code></td>
354 <td><tt><img src=".../images/userphotos/Tony.gif" alt="Tony Bibbs"></tt></td>
355 <td>User photo of the story author, if provided (and user photos are <a
356 href="config.html#desc_allow_user_photo">enabled</a>). For anonymous
357 users, this will be an empty string, unless use of <a
358 href="config.html#desc_use_gravatar">Gravatars</a> is enabled or a <a
359 href="config.html#desc_default_photo">default photo</a> is
360 configured.</td></tr>
361 <tr><td><code>author_photo</code></td>
362 <td><i>(see above)</i></td>
363 <td>Same as <tt>{contributedby_photo}</tt></td></tr>
364 <tr><td><code>camera_icon</code></td>
365 <td>small camera icon and link to the author's user profile</td>
366 <td>Displays the camera icon (the same as in the Who's Online block) and
367 links to the author's user profile if they have uploaded a user photo
368 (never displayed for anonymous authors).</td></tr>
371 <p>The following variables are only available if topic icons are enabled for
372 the story <em>and</em> the user has not disabled topic icons in his/her
373 display preferences:</p>
375 <table border="1" width="100%" cellpadding="2">
376 <tr><th style="width:8%">Variable</th>
377 <th style="width:29%">Example</th>
378 <th style="width:63%">Description</th></tr>
379 <tr><td><code>story_anchortag_and_image</code></td>
380 <td><code><a href="http://www.example.com/<br>index.php?topic=Geeklog"><img src="..." ...></a></code> <small>(shortened)</small></td>
381 <td>Topic icon for the story's topic, enclosed in a link to the site's
382 index page, sorted by topic.</td></tr>
383 <tr><td><code>story_anchortag_and_image_no_align</code></td>
384 <td><code><a href="http://www.example.com/<br>index.php?topic=Geeklog"><img src="..." ...></a></code> <small>(shortened)</small></td>
385 <td>Same as <code>{story_anchortag_and_image}</code> but without the
386 <code>align</code> attribute for the topic image.</td></tr>
387 <tr><td><code>story_topic_image</code></td>
388 <td><code><img src="http://www.example.com/<br>images/topics/topic_gl.gif" align="right" alt="Geeklog" title="Geeklog"></code></td>
389 <td>Topic icon for the story.</td></tr>
390 <tr><td><code>story_topic_image_no_align</code></td>
391 <td><code><img src="http://www.example.com/<br>images/topics/topic_gl.gif" alt="Geeklog" title="Geeklog"></code></td>
392 <td>Same as <code>{story_topic_image}</code> but without the
393 <code>align</code> attribute for the topic image.</td></tr>
394 <tr><td><code>story_topic_image_url</code></td>
395 <td><code>http://www.example.com/<br>images/topics/topic_gl.gif</code></td>
396 <td>Just the URL of the topic icon.</td></tr>
397 <tr><td><code>story_topic_id</code></td>
399 <td>Id (internal name) of the topic, e.g. to be used in links.</td></tr>
400 <tr><td><code>story_topic_name</code></td>
401 <td>General News</td>
402 <td>Topic name (as seen on the Sections block).</td></tr>
403 <tr><td><code>story_topic_url</code></td>
404 <td><code><a href="http://www.example.com/<br>index.php?topic=General"></code></td>
405 <td>URL to your site's index page, so that only stories with the story's
406 topic are displayed.</td></tr>
409 <p>The following variables are only available when the current user has the
410 permissions to edit a story:</p>
412 <table border="1" width="100%" cellpadding="2">
413 <tr><th style="width:8%">Variable</th>
414 <th style="width:29%">Example</th>
415 <th style="width:63%">Description</th></tr>
416 <tr><td><code>edit_link</code></td>
417 <td><code><a href=".../admin/story.php<br>?mode=edit&sid=20021022234959146">edit</a></code></td>
418 <td>Link to open the story in the admin's story editor.</td></tr>
419 <tr><td><code>edit_icon</code></td>
420 <td><code><a href=".../admin/story.php<br>?mode=edit&sid=20021022234959146"><img src=".../images/edit.gif"></a></code></td>
421 <td>An icon linking to the admin's story editor to edit the story.</td></tr>
422 <tr><td><code>edit_url</code></td>
423 <td><tt>http://www.example.com/admin/story.php<br>?mode=edit&sid=20021022234959146</tt></td>
424 <td>URL to open the story in the admin's story editor</td></tr>
425 <tr><td><code>lang_edit_text</code></td>
427 <td>The word "edit" in the user's preferred language.</td></tr>
431 <a href="http://wiki.geeklog.net/">The Geeklog Documentation Project</a><br>
432 All trademarks and copyrights on this page are owned by their respective owners. Geeklog is copyleft.