Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-15-2014, 04:33 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 91,101
Kyttias is on a distinguished road
Arrow 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:
$mysidia Registry::get("mysidia");
$this->assign("logged_in",$mysidia->user->isloggedin);
$this->assign("username",$mysidia->user->username); 
$this->assign("cash",$mysidia->user->getcash());
$messages $mysidia->db->select("messages", array(), "touser='{$mysidia->user->username}' and status='unread'")->rowCount(); 
$this->assign("messages",$messages); 
This has assigned four variables to Smarty.

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}
The above will:
- 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.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -5. The time now is 04:38 PM.

Currently Active Users: 270 (0 members and 270 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636