Login Status widget with external widget templates - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Login Status widget with external widget templates

  • Login Status widget with external widget templates
  • It seems that it is not possible to change the LoggedInLayoutTemplatePath and LoggedOutLayoutTemplatePath properties of the LoginStatus widget. Is this a bug?
  • Hello Nelson,

    Yes, there is a know issue about the template paths of the control. I suggest that you should use the standard ASP.NET analogs in a custom or user controls as a workaround.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  • Is there any progress on resolving this?  Thanks
  • Hi Ian,

    The status of the issue is not fixed.  There is a workaround that I see if you override
    LoggedInLayoutTemplatePath and LoggedOutLayoutTemplatePath, but changing the properties though the control designer does not work.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  • Can you go into a bit more depth explaining the work around?

    Thanks!

    -Ben
  • @Ivan:

    Per your last post: "There is a workaround that I see if you override
    LoggedInLayoutTemplatePath and LoggedOutLayoutTemplatePath, but changing the properties though the control designer does not work."

    The "LoggedInLayoutTemplatePath" and "LoggedInLayoutTemplatePath" values aren't persisted when edited via the designer.  Any info on the work around would be appreciated.

    Thanks--Steve
  • Hi Stevev,

    You have to inherit from LoginStatusControl and override the virtual LoggedInLayoutTemplatePath and LoggedOutLayoutTemplatePath public properties.



    Regards,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  • I've tried to do this but my solution doesn't work. Can you give me an example ?

    Thanks
  • Hi,

    Here is a sample code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Sitefinity.Web.UI.PublicControls;
     
    namespace SitefinityWebApp
        public class LoginStatusControlSample : LoginStatusControl
        
     
            protected override string LoggedInLayoutTemplateName
            
                get
                
                    return null;
                
     
            
     
            protected override string LoggetOutLayoutTemplateName
            
                get
                
                    return null;
                
            
     
     
            public override string LoggedInLayoutTemplatePath
            
                get
                
                    return "~/MyPRefix/Telerik.Sitefinity.Samples.Resources.LoggedInLayoutTemplatePath.ascx";// here return your template using Virtual Path provider
                
     
            
     
            public override string LoggedOutLayoutTemplatePath
            
                get
                
                    return "~/MyPRefix/Telerik.Sitefinity.Samples.Resources.LoggedOutLayoutTemplatePath.ascx";";//here return your template using Virtual Path provider
                
     
            
           
        


    www.sitefinity.com/.../taking_advantage_of_the_virtual_path_provider_in_sitefinity_4_1.aspx

    Regards,
    Ivan Dimitrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  • Anyone else experiencing this issue... lets vote it up so they'll finally fix it.  Still an issue in the latest version a year and a half later... only now the workaround doesn't even work it seems.

    www.telerik.com/.../pits.aspx
  • I overrode all three functions below, the designer is working fine but I still can't get the right template to show.  Any update on this?

    public class LoginStatusControl : Telerik.Sitefinity.Web.UI.PublicControls.LoginStatusControl
        
            private string _LoggedInLayoutTemplatePath;
            private string _LoggedOutLayoutTemplatePath;
     
     
            [Browsable(false)]
            public override string LayoutTemplatePath
            
                get
                
                    if (!this.IsLoggedIn)
                    
                        return this.LoggedOutLayoutTemplatePath;
                    
                    return this.LoggedInLayoutTemplatePath;
                
                set
                
                
            
     
            [WebDisplayName("DisplayName_LoggedInLayoutTemplatePath"), Telerik.Sitefinity.Web.UI.PublicControls.Attributes.WebCategory("ControLCategory_Templates")]
            public override string LoggedInLayoutTemplatePath
            
                get
                
                    if (_LoggedInLayoutTemplatePath.IsNullOrEmpty())
                    
                        return ControlUtilities.ToVppPath("Telerik.Sitefinity.Resources.Templates.PublicControls.LoginStatus_LoggedIn.ascx");
                    
     
                    else
                    
                        return _LoggedInLayoutTemplatePath;
                    
                
                set
                
                    base.LayoutTemplatePath = value;
                    _LoggedInLayoutTemplatePath = value;
                
            
     
            [WebDisplayName("DisplayName_LoggedOutLayoutTemplatePath"), Telerik.Sitefinity.Web.UI.PublicControls.Attributes.WebCategory("ControLCategory_Templates")]
            public override string LoggedOutLayoutTemplatePath
            
                get
                
                    if (_LoggedOutLayoutTemplatePath.IsNullOrEmpty())
                    
                        return ControlUtilities.ToVppPath("Telerik.Sitefinity.Resources.Templates.PublicControls.LoginStatus_LoggedOut.ascx");
                    
     
                    else
                    
                        return _LoggedOutLayoutTemplatePath;
                    
                
                set
                
                    base.LayoutTemplatePath = value;
                    _LoggedOutLayoutTemplatePath = value;
                
            
        
  • Hi,

    Unfortunately this is not fixed yet. I'll increase the priority of the PITS and we'll do out best to fix it in one of our next Releases.

    As for your solution - you should better override the LayoutTemplateName property and use the same logic as in the LayoutTemplatePath:

    protected override string LayoutTemplateName
            
                get
                
                    return this.IsLoggedIn ? this.LoggedInLayoutTemplateName : this.LoggetOutLayoutTemplateName;
                
            
     
            public override string LayoutTemplatePath
            
                get
                
                    return this.IsLoggedIn ? this.LoggedInLayoutTemplatePath : this.LoggedOutLayoutTemplatePath;
                
                set
                
                    // does nothing
                
            

    Please accept my apologies for the caused inconvenience.

    Regards,
    Veronica Milcheva
    the Telerik team
    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
  • Veronica your suggested code doesn't seem to work.

    Here is what I use but my controls never get displayed....

    using System;
    using System.Linq;
    using Telerik.Sitefinity.Web.UI.PublicControls;
     
    namespace SitefinityWebApp.CustomWidgets.Login
        public class CustomLoginStatus : LoginStatusControl
        
            protected override string LayoutTemplateName
            
                get
                
                    return this.IsLoggedIn ? this.LoggedInLayoutTemplateName : this.LoggetOutLayoutTemplateName;
                
            
            public override string LayoutTemplatePath
            
                get
                
                    return this.IsLoggedIn ? this.LoggedInLayoutTemplatePath : this.LoggedOutLayoutTemplatePath;
                
                set
                
                    // does nothingv dsf
                
            
            protected override string LoggedInLayoutTemplateName
            
                get
                
                    return "~/SfLocal/SitefinityWebApp.CustomWidgets.Login.LoginStatus_LoggedIn.ascx";
                
            
     
            protected override string LoggetOutLayoutTemplateName
            
                get
                
                    return "~/SfLocal/SitefinityWebApp.CustomWidgets.Login.LoginStatus_LoggedOut.ascx";
                
            
     
            public override string LoggedInLayoutTemplatePath
            
                get
                
                    return "~/SfLocal/SitefinityWebApp.CustomWidgets.Login.LoginStatus_LoggedIn.ascx";
                
            
            public override string LoggedOutLayoutTemplatePath
            
                get
                
                    return "~/SfLocal/SitefinityWebApp.CustomWidgets.Login.LoginStatus_LoggedOut.ascx";
                
            
        
  • Hi Boyan,

    yes that's also what was posted by Patrick Dunn on his blog, it's not a very nice nor elegant solution, and I already brought other's attention to a potential problem with the beginning of that RenderCacheSubsitutionMarkup method:

    ClaimsIdentityProxy user = ClaimsManager.GetCurrentIdentity();

    will not be null even if its an unauthenticated user. ClaimsManager returns a user object anyway the only difference is that user.Name = "Anonymous";

    ;-)