convert these tpl tags to php
422
MVP
I am porting a site for a Vanilla Member .. and the default.master file is tpl.
Ive done most of the conversion, but a little stumped with this ...
{if $User.SignedIn}
{$User.Name}
{if $User.CountNotifications}
{$User.CountNotifications}
{/if}
Inbox
{if $User.CountUnreadConversations}
{$User.CountUnreadConversations}
{/if}
{if CheckPermission('Garden.Settings.Manage')}
Dashboard
{/if}
{/if}
{link path="signinout"}
{if !$User.SignedIn}
Apply for Membership
{/if}
Download
Hosting
Documentation
Community
Addons
Blog
Home
I need to make this current with new vb versions ( 2.0.18.4 )
Plus its for the default.master.php version ...
Any ideas.. merely swapping out {if with <?php if .... etc ???
0
Answers
Here's one
{if $User.Signedin }== if ($Session->IsValid())
Okies awesome.. Gonna have to go thru it a line at a time lol.
if i free up some time i can give it a run through.. i have all of that code in plguins already written..
Would appreciate tat thankyou
no rush.
no warranties, guarantees or attribution for what snippets were stolen from where...
<?php //Get the environment $Session = Gdn::Session(); //{if $User.SignedIn} if ($Sender->Menu && $Session->IsValid()) { // {$User.Name} $Name = $Session->User->Name; // {if $User.CountNotifications} // {$User.CountNotifications} // {/if} $CountNotifications = $Session->User->CountNotifications; if (is_numeric($CountNotifications) && $CountNotifications > 0) $Name .= ' '.$CountNotifications.''; if (urlencode($Session->User->Name) == $Session->User->Name) $ProfilePath = $Session->User->Name; else $ProfilePath = $Session->UserID.'/'.urlencode($Session->User->Name); $this->Menu->AddLink('User', $Name, '/profile/'.$ProfileSlug, array('Garden.SignIn.Allow'), array('class' => 'UserNotifications')); //Inbox //{if $User.CountUnreadConversations} // {$User.CountUnreadConversations} // {/if} $Inbox = T('Inbox'); $CountUnreadConversations = $Session->User->CountUnreadConversations; if (is_numeric($CountUnreadConversations) && $CountUnreadConversations > 0) $Inbox .= ' '.$CountUnreadConversations.''; $Sender->Menu->AddLink('Conversations', $Inbox, '/messages/all', FALSE, array('Standard' => TRUE)); // {if CheckPermission('Garden.Settings.Manage')} // Dashboard // {/if} $this->Menu->AddLink('Dashboard', T('Dashboard'), '/dashboard/settings', array('Garden.Settings.Manage')); // {link path="signinout"} $this->Menu->AddLink('SignOut', T('Sign Out'), SignOutUrl(), FALSE, array('class' => 'NonTab SignOut')); } // {if !$User.SignedIn} else { // Apply for Membership $Url = RegisterUrl($this->_Sender->SelfUrl); if(!empty($Url)) $Sender->Menu->AddLink('Apply', T('Apply for Membership'), $Url)); }//{/if} /?>i assumed that all of the tpl was trying to shove stuff into the menu bar... so i called addlink on urrything.
If hbf wouldn't have solved it, I would have given this advice:
In the Smarty Cache directory is all templates converted to PHP maybe it uses a lot of custom PHP in those PHP files, but still... :-) Luckily the code of hbf looks great, as always... :-)
Normally the {/if} of Smarty are shorthand for the code
and the normal {if} statements are normal if's in PHP. Lots of other things is shortened PHP code, for example {link} is a custom function, so it's tougher to figure out :-)
hmm still working my way thru it lol.
{if $User.SignedIn} < a href="{link path="profile"}"> {$User.Name} {if $User.CountNotifications} < span>{$User.CountNotifications}</ span> {/if} < a href="{link path="messages/inbox"}">Inbox {if $User.CountUnreadConversations} < span>{$User.CountUnreadConversations}</ span> {/if} < /a> {if CheckPermission('Garden.Settings.Manage')} < a href="{link path="dashboard/settings"}">Dashboard</ a> {/if} {/if} {link path="signinout"} {if !$User.SignedIn} < a href="{link path="register"}">Apply for Membership</ a> {/if}this is driving me bonkers.
Do it in steps
{/if} = endif;
{if !$User.SignedIn} = if ($Session->IsValid())
{link path=...} = $this->Menu->AddLink(...)
Let's see what you have left afterwards...
The CheckPermissions functions is stuffed in the AddLink function, so that's the final step.
Right will have another go in the mornin. Cheers guys.