Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[Documentation] How can I hide the right column ( Panel ) from Guests ?

edited April 2012 in Vanilla 2.0 - 2.8

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

Best Answer

  • UnderDogUnderDog MVP
    edited April 2012 Answer ✓

    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
    }

    There was an error rendering this rich post.

Answers

  • UnderDogUnderDog MVP
    edited April 2012 Answer ✓

    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
    }

    There was an error rendering this rich post.

  • edited April 2012

    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();
    }
    ?>


  • UnderDogUnderDog MVP
    edited April 2012

    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');
    }

    There was an error rendering this rich post.

  • edited April 2012

    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,

Sign In or Register to comment.