How to enable the signin link for user

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/9/2010 9:57:08 PM
Gravatar
Total Posts 4

How to enable the signin link for user

Hi

     I want to disalbe the signin and register link in the user page , but it should be in admin page

so where we have to check this and disable this

Thanks & Regards

Hrushikesh Pradhan

3/10/2010 8:39:05 AM
Gravatar
Total Posts 2209

Re: How to enable the signin link for user

Hi Hrushikesh,

You can remove the sign-in and register links by removing the code below from your skin's layout.master file.

<portal:RegisterLink id="RegisterLink" runat="server" RenderAsListItem="true" />
<portal:LoginLink id="LoginLink" runat="server" RenderAsListItem="true" />

The links will not be on any page as the site doesn't know if the user is an admin until after they login and then there is no need for a sign-in or register link. Admins will have to know the path to the login page (/secure/login.aspx).

Hope this helps,
Joe D.

3/10/2010 8:49:03 AM
Gravatar
Total Posts 4

Re: How to disable the signin link for user

Thanks for reply

 but i want to know if admin login then how to enable the link i mean

we want that in user page we do not want any link(register,signin,site) but we will provide the url for admin to direct login

so after admin login we want to show all the link(register,signin,site,search etc) so i did not get where we have to write code

or we have to make any setting

 

 

Thanks & Regards

Hrushikesh Pradhan

3/10/2010 10:05:42 AM
Gravatar
Total Posts 2209

Re: How to enable the signin link for user

Hi Hrushikesh,

After the admin is logged in the Register and Sign-In pages will not work because the user is logged in so there is no need to show those links to a logged-in user, regardless of whether or not the user is an admin.

To remove the links from the site, you must edit the layout.master file that is used by the skin you have chosen for your site. Site skins are located in \Data\Sites\[sitenumber]\skins. In a single site installation, your sitenumber is 1.

Thanks,
Joe D.

3/10/2010 10:15:55 AM
Gravatar
Total Posts 4

Re: How to enable the signin link for user

Thanks for reply

No I mean After the admin is logged in we need to show Home,Search and Sitemap link only for admin, but we do not need

any link for user. so if i will remove

<portal:HomeLink ID="HomeLink" runat="server" RenderAsListItem="true" />

<portal:SearchInput ID="SearchInput1" LinkOnly="True" RenderAsListItem="true" runat="server" />

<portal:SiteMapLink ID="SiteMapLink2" runat="server" CssClass="sitelink" RenderAsListItem="true" />

 

these links from the layout.master file then after admin logged in above links are not comming on the page.

so i want these links after admin login not for user

please help me.

 

Thanks & Regards

Hrushikesh Pradhan

3/10/2010 10:45:51 PM
Gravatar
Total Posts 4

Re: How to disable the sitemap,search and home link for user not for admin

 

Hi

This is urgent?????????????????????

 

After the admin is logged in we need to show Home,Search and Sitemap link only for admin, but we do not need

any link for user. so if i will remove

<portal:HomeLink ID="HomeLink" runat="server" RenderAsListItem="true" />

<portal:SearchInput ID="SearchInput1" LinkOnly="True" RenderAsListItem="true" runat="server" />

<portal:SiteMapLink ID="SiteMapLink2" runat="server" CssClass="sitelink" RenderAsListItem="true" />

 

these links from the layout.master file then after admin logged in above links are not comming on the page.

so i want these links after admin login not for user

please help me.

 

Thanks & Regards

Hrushikesh Pradhan

3/11/2010 9:25:52 AM
Gravatar
Total Posts 2209

Re: How to enable the signin link for user

Hi Hrushikesh,

Sorry I didn't respond sooner. I have been a little busy.

To accomplish your goal:

Add the following to the layout.master of your skin under the <%@Master declaration.

<script runat="server">
  protected void Page_Load(object sender, EventArgs e)
  {
   PageSettings currentPageSettings = CacheHelper.GetCurrentPage();
   SiteSettings siteSettings = CacheHelper.GetSiteSettings(currentPageSettings.SiteId);
   string siteRoot = WebUtils.GetSiteRoot();
 

   if (
    (WebUser.IsAdminOrContentAdminOrRoleAdmin)
     || (
         (WebConfigSettings.UseRelatedSiteMode)
         && (WebUser.IsInRoles(siteSettings.SiteRootEditRoles))
         )
    )
   {
    hiddenlinks1.Visible = true;
    }
  }
</script>

Next, add an asp:contenplaceholder in the location you want the links to show up. Give the placeholder an ID of hiddenlinks1 and set visible=false. Here's an example:

<asp:contentplaceholder id="hiddenlinks1" runat="server" visible="false">
  <portal:SiteMapLink id="SiteMapLink2" runat="server" CssClass="sitelink" RenderAsListItem="true" />
  <portal:MyPageLink id="MyPageLink1" runat="server" RenderAsListItem="true" />
  <portal:UserProfileLink id="UserProfileLink" runat="server" RenderAsListItem="true" />
  <portal:MailboxLink id="MailboxLink1" runat="server" RenderAsListItem="true" />
  <portal:MemberListLink id="MemberListLink" runat="server" RenderAsListItem="true" />
  <portal:SearchInput id="SearchInput1" LinkOnly="True" RenderAsListItem="true" runat="server" />
  <portal:RegisterLink id="RegisterLink" runat="server" RenderAsListItem="true" />
  <portal:LoginLink id="LoginLink" runat="server" RenderAsListItem="true" />
  <portal:LogoutLink id="LogoutLink" runat="server" RenderAsListItem="true" />
</asp:contentplaceholder>

Hope this helps,
Joe D.

3/11/2010 9:46:26 AM
Gravatar
Total Posts 18439

Re: How to enable the signin link for user

I recommend do not add any <script runat="server in the layout.master page, it may break functionality of the code behind class that layout.master inherits from.

Better to just create a UserControl, embed the UserControl in layout.master and then move those link controls out of layout.master into the UserControl and put the same code in the PageLoad for the user control.

In the UserControl you would not need the contentplaceholder, the code in PageLoad could be just

if (
    (WebUser.IsAdminOrContentAdminOrRoleAdmin)
     || (
         (WebConfigSettings.UseRelatedSiteMode)
         && (WebUser.IsInRoles(siteSettings.SiteRootEditRoles))
         )
    )
   {
    this.Visible = true;
    }

else
{ this.Visible = false;}

 

Best,

Joe

3/11/2010 9:51:09 AM
Gravatar
Total Posts 18439

Re: How to enable the signin link for user

Note however, that hiding the links does not disable the functionality, users can still visit SiteMap.aspx page directly by url.

Also you cannot hide the login link because there is no way to know if the user is an admin until after he logs in. So if you hide it you hide it from everyone including admins. Once a user is signed in the login link is nver displayed but instead the logout link is shown.

Users can also still register on the site by direct navigation to the register page. However there is a site setting "Allow Users To Register" which can be set to false to disable the registration page.

Hope it helps,

Joe

3/11/2010 11:24:35 AM
Gravatar
Total Posts 2209

Re: How to enable the signin link for user

Good points Joe. I sat in the corner with a dunce cap on for 15 minutes and then I followed your advice and created a user control for this. Let me know if I missed anything. I agree this solution is purely cosmetic but I think Hrushikesh isn't after much more than that.

Create two files, AdminOnlyLinks.cs and AdminOnlyLinks.ascx.cs. Save these files in \Controls\Custom (you will have to create the Custom directory).

AdminOnlyLinks.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AdminOnlyLinks.ascx.cs" ClassName="AdminOnlyLinks.ascx" Inherits="Controls_AdminOnlyLinks" %>
<portal:SiteMapLink id="SiteMapLink2" runat="server" CssClass="sitelink" RenderAsListItem="true" />
<portal:MyPageLink id="MyPageLink1" runat="server" RenderAsListItem="true" />
<portal:UserProfileLink id="UserProfileLink" runat="server" RenderAsListItem="true" />
<portal:MailboxLink id="MailboxLink1" runat="server" RenderAsListItem="true" />
<portal:SearchInput id="SearchInput1" LinkOnly="True" RenderAsListItem="true" runat="server" />

AdminOnlyLinks.ascx.cs

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using mojoPortal.Web;
using mojoPortal.Web.UI;
using mojoPortal.Web.Framework;
using mojoPortal.Business;
using mojoPortal.Business.WebHelpers;


public partial class Controls_AdminOnlyLinks : System.Web.UI.UserControl
{

protected void Page_Load(object sender, EventArgs e)
{
PageSettings currentPageSettings = CacheHelper.GetCurrentPage();
SiteSettings siteSettings = CacheHelper.GetSiteSettings(currentPageSettings.SiteId);
string siteRoot = WebUtils.GetSiteRoot();

if (
(WebUser.IsAdminOrContentAdminOrRoleAdmin)
|| (
(WebConfigSettings.UseRelatedSiteMode)
&& (WebUser.IsInRoles(siteSettings.SiteRootEditRoles))
)
)
{
this.Visible = true;
}

else
{ this.Visible = false;}
}
}

 

Add the following to your layout.master after the <%@Master.

<%@ Register Src="~/Controls/Custom/AdminOnlyLinks.ascx" TagName="AdminOnlyLinks" TagPrefix="cc1" %>

 

Add the following to your layout.master in the location you want the links to appear.

<cc1:AdminOnlyLinks id="hiddenlinks1" runat="server" />

 

Also note:

  • The Memberlist and Mypage can be controlled with the "Roles that can view the member list page" permissions under Security in the Site Settings.
  • You can also disable Mypage by deselecting the "Enable MyPage Feature" option on the General tab in the Site Settings.
  • You can disable registration by deselecting the "Allow New Users to Register" option on the Security tab in the Site Settings.

HTH,
Joe D.

3/26/2010 10:29:03 AM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

I have come up with a customized admin panel and basically don't want it to be visible unless the user is signed in.  I tried incorporating your usercontrol suggestion I'm getting weird results.

Here's what the menu looks like when the user is signed in:  http://bit.ly/9ThUbL

The following is my usercontrol code:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AdminOnlyLinks.ascx.cs" ClassName="AdminOnlyLinks.ascx" Inherits="Controls_AdminOnlyLinks" %>
<div id="admin">
<div id="buttons">
<portal:LogoutLink id="LogoutLink" runat="server" CssClass="logoff" RenderAsListItem="false" />
<portal:SiteMapLink id="SiteMapLink1" runat="server" />
<a href="/Admin/ContentCatalog.aspx">Content Manager</a>
<a href="/Admin/PageTree.aspx">Add/Edit Pages</a>
<asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder>
</div>
<a id="show_hide" class="arrow down" href="javascript:toggleVisibility()"></a>
</div>

 

However, when I insert  <cc1:AdminOnlyLinks id="hiddenlinks1" runat="server" /> , I get the following: http://bit.ly/abpQNZ

I get an error in the log:

 

2010-03-26 12:16:42,268 ERROR mojoPortal.Web.mojoBasePage - Error setting master page. Will try setting to default skin.en-US - 131.156.71.164
System.Web.HttpParseException: Unknown server tag 'cc1:AdminOnlyLinks'. ---> System.Web.HttpParseException: Unknown server tag 'cc1:AdminOnlyLinks'. ---> System.Web.HttpException: Unknown server tag 'cc1:AdminOnlyLinks'.

I added a directive to the layout.master as like so:

<%@ Register Src="~/Controls/Custom/AdminOnlyLinks.ascx" TagName="AdminOnlyLinks" TagPrefix="cc1" %>

 

Here's the code-behind file just in case:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using mojoPortal.Web;
using mojoPortal.Web.UI;
using mojoPortal.Web.Framework;
using mojoPortal.Business;
using mojoPortal.Business.WebHelpers;


public partial class Controls_AdminOnlyLinks : System.Web.UI.UserControl
{

protected void Page_Load(object sender, EventArgs e)
{
PageSettings currentPageSettings = CacheHelper.GetCurrentPage();
SiteSettings siteSettings = CacheHelper.GetSiteSettings(currentPageSettings.SiteId);
string siteRoot = WebUtils.GetSiteRoot();

if (
(WebUser.IsAdminOrContentAdminOrRoleAdmin)
|| (
(WebConfigSettings.UseRelatedSiteMode)
&& (WebUser.IsInRoles(siteSettings.SiteRootEditRoles))
)
)
{
this.Visible = true;
}

else
{ this.Visible = false; }
}
}

You must sign in to post in the forums. This thread is closed to new posts.