Home Community Mys-Script Creative Off-Topic |
|
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
Smarty Tips: Things you can do with Templates
Mysidia is built with the Smarty template system. Here's some fun facts:
You can write multiple conditions using the {if} {elseif} {elseif} {else} {/if} style. In Smarty, you can also implement a nested {if} {/if} block. You can display the current date in your template with {$smarty.now|date_format} and it will print in the format Jul 15, 2014. For the time, check out {$smarty.now|date_format:"%H:%M"} for military time that prints 16:45, or {$smarty.now|date_format:"%I:%M %p"} for 04:45 PM. If you know how php prints dates, you can probably figure out how to customize this a ton! For fun, pop open classes/class_template.php and inside private function assignTemplateVars(){ after it's row of this->s are done, add these: PHP Code:
In your template.tpl, you can now do this: Code:
{if $logged_in} <a href="{$home}profile/view/{$mysidia->user->username}">{$username}</a> ${$cash} {$mysidia->settings->cost} <a href="{$home}messages">{$messages} Messages</a> <a href="{$home}login/logout">Log Out</a> {else} Please <a href="{$home}login/logout">Log In</a> or <a href="{$home}register">Sign Up</a>! {/if} - only display if a user is logged in - print their username, which will link to their profile - show how much currency they have and the name of your currency - show how many messages they have, and a link to go check them out - show a log out link when they are logged in - when they aren't logged in, it will ask them to log in or sign up You'll definitely want to work around this and make it pretty. ^_~ Another example might be a message that shows up 30% of the time: Code:
{if rand(0,100) <= 30} Winner! {/if}
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. Last edited by Kyttias; 04-03-2015 at 10:01 AM. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tips for theme? | Abronsyth | Templates and Themes | 6 | 01-03-2013 06:04 PM |
Any tips for writing a TOS? | Kesstryl | Feedback and Suggestions | 5 | 03-30-2012 06:37 PM |
Some Site Planning Tips | Tequila | Tutorials and Tips | 2 | 04-08-2011 09:17 AM |
Templates | CrystalShards | Suggestions and Feature Requests | 1 | 07-18-2009 12:48 PM |
templates | aroymart | Questions and Supports | 15 | 02-18-2009 01:46 PM |
What's New? |
What's Hot? |
What's Popular? |