HOME TIPS FORUMS DOWNLOADS
   »»  Tips Archive |
Themes : Smarty Theme Variables
Posted by tl001 on 2004/6/18 8:06:24 (18980 reads)
Themes

You can use pre-set smarty variables in your themes. Want to date and time your site? Want to include php codes in your theme?



Date and Time


<{$smarty.now|date_format:"%a, %b %e, %Y | %H:%M %Z"}>

You will have a short-form date and time: Fri, Jun 18, 2004 | 08:18:00 PDT

<{$smarty.now|date_format:"%A, %B %e, %Y | %H:%M %Z"}>
You will have a long-form date and time: Friday, June 18, 2004 | 08:18:00 PDT

Please be sure to check out smarty.php.net, if you want to learn more about smarty.

The time and date from smarty.now is your server’s time, may or may not be your own time. This is the drawback using it.

Use php code in the theme
<{php}>
your php codes here
<{/php}>


Official xoops smarty theme variables
<{$xoops_charset}>
Inserts the characterset info (meta tag info) e.g "iso-8859-1", "UTF-8"

<{$xoops_langcode}>
Content Language e.g. "DE", "EN"

<{$xoops_meta_keywords}>
Inserts the keyword list from the Meta/Footer settings (meta tag info)

<{$xoops_meta_description}>
Inserts the meta tag site description

<{$meta_copyright}>
Inserts the meta tag copyright text

<{$meta_robots}>
Inserts the W3C robot meta tag info

<{$meta_rating}>
Inserts the meta tag rating information

<{$xoops_sitename}>
Inserts the site name

<{$xoops_pagetitle}>
Inserts the page title

<{$xoops_theme}>
Theme's name in directory "/themes/"
e.g "default", "xt2"

<{$xoops_themecss}>
Inserts the style.css
e.g "http://www.xoops.org/themes/default/style.css"

(note, any combination of the above can be arranged to
fill out meta tag info to your liking)

<{$xoops_url}>
Inserts the site URL
e.g "http://www.xoops.org"

<{$xoops_js}>
Inserts XOOPS javascript code

<{$xoops_banner}>
Displays banners

<{foreach item=block from=$xoops_lblocks}>
<{$block}>
<{/foreach}>
Code snippet to display the left blocks

<{if $xoops_showcblock == 1}>
Tests for system settings to display center blocks

<{foreach item=block from=$xoops_ccblocks}>
<{$block}>
<{/foreach}>
Code snippet to show the center-center blocks

<{foreach item=block from=$xoops_clblocks}>
<{$block}>
<{/foreach}>
Code snippet to show the center-left blocks

<{foreach item=block from=$xoops_crblocks}>
<{$block}>
<{/foreach}>
Code snippet to show the center-right blocks

<{$xoops_contents}>
Show the news and other contents

<{if $xoops_showcblock == 1}>
Test for showing center blocks

<{if $xoops_showrblock == 1}>
Test for showing right blocks

<{foreach item=block from=$xoops_rblocks}>
<{$block}>
<{/foreach}>
Code snippet to show right blocks

<{$xoops_footer}>
Shows the footer

<{$xoops_isadmin}>
True if the visitor is Administrator

<{$xoops_isuser}>
True if the visitor is a logged in user

<{$xoops_userid}>
User ID of the member

<{$xoops_uname}>
Uname for the member

(source: xoops theme variables xoops WIKI)

Printer Friendly Page Send this Story to a Friend
The comments are owned by the poster. We aren't responsible for their content.
Poster Thread
mexedi
Posted: 2004/6/28 19:16  Updated: 2004/6/28 19:16
Just popping in
Joined: 2004/6/28
From:
Posts: 2
 Re: Smarty Theme Variables
<{$smarty.now|date_format:"%A, %B %e, %Y | %H:%M %Z"}>
You will have a long-form date and time: Friday, June 18, 2004 | 08:18:00 PDT

in Spanish

Viernes, Junio 18, 2004 | 08:18:00 PDT

it is only in ingles Smarty
tl001
Posted: 2004/6/28 19:58  Updated: 2006/3/27 13:45
Webmaster
Joined: 2004/6/10
From:
Posts: 282
 Re: Smarty Theme Variables
Another drawback using smarty

You can use a javascript to display date in Spanish

sample code
-------
 <script type="text/javascript">
<!-- // Array of month Names
var monthNames = new Array(
"January","February","March","April","May","June","July","August","September","October","November","December");
var now = new Date();
thisYear = now.getYear();
if(thisYear < 1900) {thisYear += 1900}; // Y2K correction
document.write("Today is" + " " + monthNames[now.getMonth()] + " " + now.getDate() + ", " + thisYear);
// -->
</script>

Just replace the month names with corresponding Spanish month names.

7dana (www.7dana.com) has a couple of themes (Zaja_Color is one) with a clock javascript displaying date and time. It can be easily adapted to your needs, so you may want to take a look.

[edit]Dave Lerner has a "Javascript function that emulates PHP function: string date ( string format [, int timestamp ] )", you may want to check out too.
http://dave-l.com/grafix/index.php?page=xoops
[/edit]