How to hide/remove search box from sensenet homepage for Visitors (before login)

时间:2017-03-14 10:22:04

标签: sensenet

I want to remove search box for Visitor users on the homepage of my custom sensenet site. I want to display it only after a user is logged in to the site. I tried to achieve this with making changes in the skin.css

1 个答案:

答案 0 :(得分:0)

将以下内容放在pagetemplate html' s

的末尾
<snpe:ClientContextPortlet runat="server" id="ClientContext" />

这会将json中的上下文信息添加到页面的html中,并且您将能够检查当前用户是否已登录(在这种情况下,她的名字是访问者)。 然后将以下内容添加到init.js(/Root/Skins/sensenet/scripts/init.js)

$(function(){
  if(SN.Context.currentUser.name === "Visitor")
    $('.sn-quicksearch').hide();
  else
    $('.sn-quicksearch').show();
})