View Single Post
  #1  
Old 06-17-2014, 02:47 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 130,095
Kyttias is on a distinguished road
Default Smarty and Conditional Templating~?

So I've been reading through Smarty documentation, since Mysidia is built using that templating system.

The documentation suggests we can do things such as the following in our template (.tpl) files:

PHP Code:
{if $logged_in}
Welcome, {$username}!
{else}
Please log in or sign up~
{/if} 
That's pretty neat, and conditional templating sounds fun, considering there are large portions of my menu I'd rather not display to users not signed in. Currently a $logged_in variable by that name does not exist, so only the else statement will ever appear, and I was hoping {$mysidia->user->isloggedin} and {$mysidia->user->username} would work but those are not accessible outside their scope, and, honestly, why isn't Registry::get("mysidia"); on a global scope? They're accessible in the sidebar.

My complaint with the sidebar usage is that... well... I want more freedom than that? I want to place it in anywhere in my template (.tpl) and not have to mess with deep Mysidia files every time I want to place my user's name or currency amount. If I want to display any variable on this site, I want to make full use of the Smarty templating. I think some considerations for the next version of Mysidia should be made in regards to variables accessible to us from any page, any where, any time.

In short -
Where can I/should I/do I position Registry::get("mysidia"); to make its usage global?
How do I go about shortening {$mysidia->user->username} to {$username}, {$mysidia->user->isloggedin} to {$logged_in}, and {$mysidia->user->money} {$mysidia->settings->cost} to {$currency}?

~ <3

Last edited by Kyttias; 06-17-2014 at 03:26 PM.
Reply With Quote