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 2239

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 2239

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 2239

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 2239

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

3/28/2010 4:07:44 PM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi,

Sorry it has taken me so long to respond. I have been out of the office for a couple days.

Try removing the contentplaceholder from your user control and let me know if that helps at all. I copied your code a test site of mine and having the contentplaceholder threw an error. It wasn't the same error you are posting but after removing the contentplaceholder everything worked as it should.

You may want to make sure your <%@ register line is exactly as you posted it.

HTH,
Joe D.

3/29/2010 10:18:09 AM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

Removed the ContentPlaceHolder like you suggested - didn't help.  This is what I have in the log:

 

2010-03-29 10:17:04,033 ERROR mojoPortal.Web.mojoBasePage - Error setting master page. Will try setting to default skin.en-US - 131.156.71.164
System.Web.HttpParseException: ContentPlaceHolder can only be used in .master files. ---> System.Web.HttpParseException: ContentPlaceHolder can only be used in .master files. ---> System.Web.HttpException: ContentPlaceHolder can only be used in .master files.
at System.Web.UI.WebControls.ContentPlaceHolderBuilder.Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String ID, IDictionary attribs)
at System.Web.UI.ControlBuilder.CreateBuilderFromType(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs, Int32 line, String sourceFileName)
at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty)
at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)
at System.Web.UI.Page.get_Master()
at mojoPortal.Web.mojoBasePage.SetupMasterPage()
at mojoPortal.Web.mojoBasePage.OnPreInit(EventArgs e)
2010-03-29 10:17:11,500 ERROR mojoPortal.Web.mojoBasePage - Error setting master page. Will try setting to default skin.en-US - 131.156.71.164
System.Web.HttpParseException: ContentPlaceHolder can only be used in .master files. ---> System.Web.HttpParseException: ContentPlaceHolder can only be used in .master files. ---> System.Web.HttpException: ContentPlaceHolder can only be used in .master files.
at System.Web.UI.WebControls.ContentPlaceHolderBuilder.Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String ID, IDictionary attribs)
at System.Web.UI.ControlBuilder.CreateBuilderFromType(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs, Int32 line, String sourceFileName)
at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty)
at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
--- End of inner exception stack trace ---
at System.Web.UI.TemplateParser.ProcessException(Exception ex)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)
at System.Web.UI.Page.get_Master()
at mojoPortal.Web.mojoBasePage.SetupMasterPage()
at mojoPortal.Web.mojoBasePage.OnPreInit(EventArgs e)

3/30/2010 11:45:53 AM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hello,

I'm sorry but that doesn't make much sense. How would you get an error about ContentPlaceHolders only being used in master files after you have removed it from the code?

When I am troubleshooting something like this, I use the Clear Log button to clear the log and then when it reloads the page, the only data in the log are the errors encountered when generating that page. This ensures you aren't looking at old errors and makes finding the errors a lot easier.

I have copied the code I gave you to an entirely new site and it is working as expected. You may want to see if you make the code I posted work before modifying it and then post your results.

HTH,
Joe D.

3/30/2010 11:46:49 AM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi,

I just wanted to say that I really like the site design you have created. Great Job!

Thanks,
Joe D.

3/30/2010 4:24:29 PM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

Joe,

I previously tried commenting out the ContentPlaceHolder using <!-- and -->, but that did not work apparently.  I took that out completely and that resolved this "issue."  However, the real problem is that I do need those links in there regardless.  Also, even now that the ContentPlaceHolder is out, the rest of the links don't show up all of a sudden.

How do I go about this?

3/31/2010 1:54:34 PM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

Thanks for the complements :)

Another important detail is that if I do take out " <asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder>" and place it in the AdminOnlyLinks control, then mojoPortal complaints about the lack of pageEditContent in the layout.master.

So I how do I make sure that AdminOnlyLinks contains pageEditContent w/o causing any problems here?
 

4/9/2010 9:39:42 AM
Gravatar
Total Posts 156

Re: How to enable the signin link for userNo

Nothing hmm...

4/9/2010 9:53:52 AM
Gravatar
Total Posts 18439

Re: How to enable the signin link for user

Hi,

<asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder> can only exist in layout.master, you must leave it there and not put it inside a UserControl.

However, that placeholder is only used if the individual admin links do not exist in the layout.master then the admin/edit links will be added inside it. However the admin/edit links are already shown/hidden based on user roles so only users with correct roles will see those. Most of the included skins have the admin/edit links directly in layout.master ie in the admin toolbar at the bottom.

You could try marking the pageEditContent placeholder with Visible="false" in layout.master and then add those individual links to your usercontrol

<portal:AdminMenuLink id="lnkAdminMenu" runat="server" />
  <portal:FileManagerLink id="lnkFileManager" runat="server" />
  <portal:NewPageLink id="lnkNewPage" runat="server" />
  <portal:PageEditFeaturesLink id="lnkPageContent" runat="server" />
  <portal:PageEditSettingsLink id="lnkPageSettings" runat="server" />

Hope it helps,

Joe

4/9/2010 9:57:00 AM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi,

Sorry again for the delay.

You shouldn't take <asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder> out of the layout.master. The ContentPlaceHolder I mentioned you should remove is the one that you had in your AdminOnlyLinks.ascx file.

I will create a zip for this control and put in the downloads page on my website. I will post here when I have done that. Once you have this code working, you can modify it for your own styling.

Thanks,
Joe D

4/9/2010 10:23:07 AM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi,

I have created a download on my Website for this control. You can browse to http://i7media.net/downloads, click mojoPortal and then you will see the AdminOnlyLinks.zip download.

HTH,
Joe D.

4/9/2010 11:14:30 AM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

Thank you so much guys, this helps.  Joe, I like your suggestion for making it invisible and including the admin controls directly.  There's only one thin missing - the workflow dropdown.  What's the control for that?

4/14/2010 11:59:47 AM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

knock knock, anybody there?  I'd really appreciate if you guys could just supply me with a control for the workflow dropdown.

4/14/2010 1:14:20 PM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi,

Sorry I missed your reply. The control that will generate the drop-down is:

<asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder>

Thanks,
Joe D.

4/15/2010 1:47:40 PM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

Ok, but that's going to display the rest of the controls in it as well and that's exactly what I DO NOT need because I have those admin links in my own customized admin panel.   That's why recommended that I set PageEditContent visibility to false and included the individual controls for each admin link into my custom admin panel.

4/15/2010 2:30:41 PM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi,

No that control will not display the other items. When the Admin Toolbar was added to mojoPortal, this control was changed to only show the workflow dropdown if the admin links were already on the page.

If the control is displaying the admin links, it probably due to the IDs for those controls being different than what mojoPortal is expecting.

The original intent of the user control I posted on this thread wasn't to hide the admin links from people who aren't admins. It was to hide other links like SiteMap, Search and user defined links from non-admins. While the solution only hides the links and doesn't secure pages, it is what the original poster wanted.

Are you including any of the controls below in your user control?

<portal:AdminMenuLink id="lnkAdminMenu" runat="server" />
<portal:FileManagerLink id="lnkFileManager" runat="server" />
<portal:NewPageLink id="lnkNewPage" runat="server" />
<portal:PageEditFeaturesLink id="lnkPageContent" runat="server" />
<portal:PageEditSettingsLink id="lnkPageSettings" runat="server" />

If you do, that will pose an issue. What I have done on other sites when I want to include links to other admin pages like "Content Manager" and "Add/Edit Pages" is put links to those pages inside of my user control and then add my user control to my layout.master in the location that the rest of my admin links appear. So if my links were in a simple list, it would look something like this:

<ul>
  <cc1:AdminOnlyLinks id="AdminOnlyLinks1" runat="server" />
  <li><portal:AdminMenuLink id="lnkAdminMenu" runat="server" /></li>
  <li><portal:FileManagerLink id="lnkFileManager" runat="server" /></li>
  <li><portal:NewPageLink id="lnkNewPage" runat="server" /></li>
  <li><portal:PageEditFeaturesLink id="lnkPageContent" runat="server" /></li>
  <li><portal:PageEditSettingsLink id="lnkPageSettings" runat="server" /></li>
  <li><asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder></li>
</ul>

 My User Control would look like this:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AdminOnlyLinks.ascx.cs" ClassName="AdminOnlyLinks.ascx" Inherits="Controls_AdminOnlyLinks" %>
<portal:LogoutLink id="LogoutLink" runat="server" CssClass="logoff" RenderAsListItem="true" />
<portal:SiteMapLink id="SiteMapLink1" runat="server" RenderAsListItem="true" />
<li><a href="/Admin/ContentCatalog.aspx">Content Manager</a></li>
<li><a href="/Admin/PageTree.aspx">Add/Edit Pages</a></li>

When this renders in my browser, it would look like this:

<ul>
  <li><a class="sitelink logoff" href="/Secure/Logoff.aspx">Sign Out</a></li> 
  <li><a class="sitelink" href="/SiteMap.aspx">Sign Out</a></li>
  <li><a href="/Admin/ContentCatalog.aspx">Content Manager</a></li>
  <li><a href="/Admin/PageTree.aspx">Add/Edit Pages</a></li>
  <li><a class="adminmenulink" href="/Admin/AdminMenu.aspx">Administration</a></li>
  <li><a class="filemanlink" href="/Dialog/FileManagerDialog.aspx">File Manager</a></li>
  <li><a class="newpagelink" href="/Admin/PageSettings.aspx?start=0">New Page</a></li>
  <li><a class="pageeditlink" href="/Admin/PageLayout.aspx?pageid=0">Edit This Page</a></li>
  <li><a class="pagesettingslink" href="/Admin/PageSettings.aspx?pageid=0">Page Settings</a></li>
  <li><select class="ddworkflow" name="ctl01$pageEditContent$ctl00">
          <option value="WorkInProgress" selected="selected">Work in Progress</option>
          <option value="Live">Live Content</option>
        </select>
  </li>
</ul>

 

HTH,
Joe D.

4/15/2010 3:04:39 PM
Gravatar
Total Posts 18439

Re: How to enable the signin link for user

Hi Joe,

The problem is it will not see those controls inside a usercontrol, it will only see them if they are in the master page and if it does not see them it will load them in the content placeholder. The workflow dropdown will be loaded into the <asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder> and this must be in layout.master.

So really there is currently no way for him to have the workflow control inside his usercontrol and given how the workflow system works I think it would be difficult to make it possible to have it inside a usercontrol. 

So currently the pageEditContent must be visible in order to use the workflow, but if it is visible it will also load the admin links.

The best I can do is add a web.config setting to make it not load the admin links in pageEditContent, but it must load the workflow dropdown there, I cannot change that easily.

I really still don't understand why it is needed to wrap these links inside a usercontrol, they only appear to users signed in in the correct roles as they are, so no extra wrapper control is needed to hide them.

Best,

Joe

4/15/2010 3:25:37 PM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi Joe,

I think you may have misread my last post. I mentioned the id's of the admin link controls. Further, in my example the admin control links aren't inside of the user control.

I think we are thinking the same thing because I also mentioned that the original user control I wrote was specifically for hiding links from non-admins that aren't already hidden.

What alkos333 is trying to do is put all of his links including the admin control links inside of his user control which we have establish will not work. What he needs to do is put his special links that he wants hidden in his user control and all others including the pageEditContent ContentPlaceHolder directly inside the layout.master.

Thanks,
Joe D.

4/15/2010 3:45:43 PM
Gravatar
Total Posts 18439

Re: How to enable the signin link for user

Sorry, I thought he was still wanting to put them inside the usercontrol.

Best,

Joe

4/15/2010 4:31:07 PM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

The reason I want all of my controls in the user  control is because they are wrapped in the admin div which is styled, etc and I want the entire div to disappear.  If I have some of the additional links in control and if PageEditLink is in layout.master, this won't be possible.  Is there a different way to accomplish what I'm trying to do right now?

This is what my current user control looks lik: http://pastebin.com/ynjxEAbu

4/15/2010 4:44:20 PM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi,

Put this in your layout.master:

<portal:AutoHidePanel ID="ah1" runat="server">
  <div id="admin">
    <a id="show_hide" class="arrow left" href="javascript:toggleVisibility()"></a>
    <div id="buttons">
      <cc1:AdminOnlyLinks id="AdminOnlyLinks1" runat="server" />
      <portal:AdminMenuLink id="lnkAdminMenu" runat="server" />
      <portal:FileManagerLink id="lnkFileManager" runat="server" />
      <portal:NewPageLink id="lnkNewPage" runat="server" />
      <portal:PageEditFeaturesLink id="lnkPageContent" runat="server" />
      <portal:PageEditSettingsLink id="lnkPageSettings" runat="server" />
      <asp:ContentPlaceHolder ID="pageEditContent" runat="server"></asp:ContentPlaceHolder>
    </div>
  </div>
</portal:AutoHidePanel>

Remove these lines from your user control:

<div id="admin">
  <a id="show_hide" class="arrow left" href="javascript:toggleVisibility()"></a>
  <div id="buttons">
 

<portal:AdminMenuLink id="lnkAdminMenu" runat="server" />
<portal:FileManagerLink id="lnkFileManager" runat="server" />
<portal:NewPageLink id="lnkNewPage" runat="server" />
<portal:PageEditFeaturesLink id="lnkPageContent" runat="server" />
<portal:PageEditSettingsLink id="lnkPageSettings" runat="server" />

 

</div>
</div>

Remove the JavaScript from your user control and put it in your layout.master.

The <portal:AutoHidePanel is just a simple control that inherits from <asp:Panel, what it does is look for child controls that inherit from WebControl (like the admin links), it looks at all its child controls and if there are no WebControls with their visible property set to true then it makes it's own Visible property false. It doesn't care about the other literal html that it may contain so it doesn't matter if that stuff is visible or not, it only cares if it has at least one visible WebControl contained within it.

HTH,
Joe D.

4/15/2010 8:48:21 PM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

Joe,

An enourmous thanks for all of your help.  All of this finaly makes sense and it's working flawlessly.  Sorry for bothering you guys so much with this.  It's just that I'm new to your product and have not familiarized myself with the internal set-up of all the controls, etc.

Thanks again for all the time and effort!

 

Best,
Alex

4/15/2010 8:57:21 PM
Gravatar
Total Posts 2239

Re: How to enable the signin link for user

Hi Alex,

I'm glad you got it working. I think I'm going to make a blog post out of this so others will know how to do exactly what you are doing. :-)

Thanks,
Joe D.

4/15/2010 9:12:55 PM
Gravatar
Total Posts 156

Re: How to enable the signin link for user

Joe,

This is a good idea.  I am sure quite a few people might attempt this sometime down the road and it's not as straight forward as one might expect it to be.  Here's my experience:

I did not like the default admin bar - I wanted ours to be on the side and I wanted to add quite a few more links to it. Also, I only wanted it to show up when the user was logged in.

1.  My earliest attempt was to have everything in AutoHide panel b/c I initially thought it was hidden/shown when user was logged out/in.  However, this wasn't true - it only disappeared when there were no other asp controls in it and disregarded everything else.

2.  I realized I needed to write a custom control, but decided to search the forums to see if anybody has attempted something similar - just didn't want to re-invent the wheel :).  That's how I stumbled upon AdminOnlyLinks control.  However, I misunderstood its intent either.  I thought it was intended to hide all of the admin links, but its soul purpose was to hide controls which were not already included in pageEditContent.  I thought moving everything into this custom control, including pageEditContent would work.  However, layout.master requires pageEditContent to be present.  I was completely stuck at this point.

3.  Then I discovered that each of the links in the pageEditContent had a separate control assigned to it (except a dropdown), so I added those to my custom control and set the pageEditContent's visibility in layout.master to false.  However, this had a shortcoming of hiding the workflow dropdown menu.

4.  Finally, you clarified everything by using a combination of things.  Since I had special styling applied to my <div id="admin"></div> and I wanted the entire thing hidden, I had to include the entire thing into an AutoHide panel, so that it would hide the "admin" div when there were no asp controls present inside.  pageEditContent place holder hides the links included in it by default along witht he dropdown and the AdminOnlyLinks hides all other links that I decided to add.  AutoHide panel, in turn, hides the remaining HTML since no asp controls are present inside of it once the user logs out.


Hope this  summary of my adventure will help you organize your future tutorial. :)

 

Thanks again for your dedicated support, guys!

 

Best,
Alex
 

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