Hi guys,
I'm still very new to Vanilla Forums. and need some help.
I would like to make my forum to be a closed community which only registered users can see everything.
I unchecked everything at the Guest Role Setting page ( yoursite.com/role/edit/2 ) so guests can only see the header/footer, title logos, basic menu and log in/register forms. Until this part, I have no problem. Vanilla is perfect.
But here's the thing I have to solve.
Guests can still see the whole right column ( id="Panel" ). But I would like to show GuestBox ( id="GuestBox") only for guests in the right column. And hide the rest of right column from guests.
Is anyone can tell me how to do it ? I'm only a frontend designer and very little experience with PHP or any programming.
So any help will be greatly appreciated.
Thank you
Pon
UnderDog
mod
Open themes/views/defaul.master.php (or .tpl) For TPL is the following example:
{if $User.SignedIn}
Do some coding like show the Panel Asset
{/if}
For PHP is the following example:
$Session = Gdn::Session();
if ($Session->IsValid())
{
Show the Panel Asset
} else
{
Show only the Guest Box asset
}
Answers
Hi UnderDog,
Thank you very much for your reply. But I'm still wondering what to be written in "Show the Panel Asset" part of default.master.php.
$Session = Gdn::Session();
if ($Session->IsValid())
{
Show the Panel Asset
} else
{
Show only the Guest Box asset
}
---------------------------------
My code is like this now.
---------------------------------
$Session = Gdn::Session();
if ($this->Menu) {
$this->Menu->AddLink('Linktitle', T('About'), '/categories/office');
//$this->Menu->AddLink('Linktitle', T('Topics'), '/categories/all');
$this->Menu->AddLink('Dashboard', T('Admin'), '/dashboard/settings',
array('Garden.Settings.Manage'));
if ($Session->IsValid()) {
$Name = $Session->User->Name;
$CountNotifications = $Session->User->CountNotifications;
if (is_numeric($CountNotifications) && $CountNotifications > 0)
$Name .= ' < span class="Alert" >'. $CountNotifications.'';
if (urlencode($Session->User->Name) == $Session->User->Name)
$ProfileSlug = $Session->User->Name;
else
$ProfileSlug = $Session->UserID.'/'.urlencode($Session->User->Name);
$this->Menu->AddLink('User', $Name, '/profile/'.$ProfileSlug, array('Garden.SignIn.Allow'),
array('class' => 'UserNotifications'));
$this->Menu->AddLink('SignOut', T('Sign Out'), SignOutUrl(), FALSE, array('class' =>
'NonTab SignOut'));
} else {
$Attribs = array();
if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE)
$Attribs['class'] = 'SignInPopup';
$this->Menu->AddLink('Entry', T('Sign in'), SignInUrl($this->SelfUrl), FALSE, array('class' => 'NonTab'), $Attribs);
}
echo $this->Menu->ToString();
}
?>
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Scroll waaayyy down in that same default.master.php file.
Try to find the word 'Assed' in that same file. It's close to the
<
div id="Panel">It's usually something like
$this->RenderAsset('Panel')Apply the code I showed above:
if ($Session->IsValid()) { $this->RenderAsset('Panel'); } else { $this->RenderAsset('GuestBox'); }What to do if I get a Bonk Error?
Vanilla Wiki : Join and help edit our Wiki! | View all Vanilla issues on GitHub | Report a new Vanilla issue on GitHub
Deploying a new Forum and adding a Theme | Give thanks to the Vanilla Developers!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Hi UnderDog,
Thank you so much for your help. I really appreciate it.
But I still have problems...
I tried it. but GuestBox is included in Panel. And I don't know how to separate them.
One more thing is that my right column includes other extra things that I added to default.master.php like Facebook Like box or Google Adsense Ads. Those things makes this right column very long... so I need to hide them together with 'Panel' from Guests.
Is there any way that I put those extra things into "Panel".
or
Is there any easy simple code you can write to hide them ? I need some simple code which surround something to hide it from guests.
I tried to use the code you showed me above like...
if ($Session->IsValid())
{
$this->RenderAsset('Panel');
$this->RenderAsset('OtherThings');
}
but it ended up with errors...
Hope you get what I'm trying to explain here. I wish I knew some PHP...but I don't. Need your help.
Thank you,
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •