More in this section

Forums / Developing with Sitefinity / Conditional Popup Template

Conditional Popup Template

2 posts, 0 answered
  1. Jodie
    Jodie avatar
    59 posts
    Registered:
    09 Oct 2012
    04 Dec 2009
    Link to this post
    Hi guys,

    We have a situation where we want to dynamically add a template to a pop-up page depending on if the user has opened it from our site or has followed it from a link on an external site (a search page, affiliate site etc).

    The situation:

    In the site we have the following master pages: Site.Master, PopUp.Master;
    PopUp.Master is a standalone master page with no site frame, header, footer etc. In the sf admin of the site we have pages that use PopUp.master and are displayed using a modal window script from links on the site and retrieved using ajax. 
    What I would like to do is when the page is opened from an external link is attach the Site.master to PopUp.master, get the content that would have loaded for that popup and place it in a different contentplaceholder od Site.Master to be displayed.

    This is what I currently have in PopUp.Master:

     

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
            Dim Page As Telerik.Cms.Web.CmsPageBase = DirectCast(Me.Page, Telerik.Cms.Web.CmsPageBase)  
            If Not Page.PageMode = Telerik.Cms.Web.CmsPageMode.Preview Or Page.PageMode = Telerik.Cms.Web.CmsPageMode.Edit Or Page.PageMode = Telerik.Cms.Web.CmsPageMode.Admin Then  
                If Not Me.Request.UrlReferrer Is Nothing Then  
                    Dim Ref As String = Me.Request.UrlReferrer.ToString  
     
                    If Ref.Contains("oursite.com") Then  
                        RenderPopup()  
                    End If  
                Else  
                    RenderFullPage()  
                End If  
            End If  
        End Sub  
     
        Private Sub RenderFullPage()  
            Dim Manager As New Telerik.Cms.CmsManager()  
            Dim Node As Telerik.Cms.Web.CmsSiteMapNode = DirectCast(SiteMap.CurrentNode, Telerik.Cms.Web.CmsSiteMapNode)  
            Dim CurrentPage As Telerik.Cms.ICmsPage = Node.GetCmsPage  
            Dim PageContent As StringString = String.Empty  
     
            If CurrentPage.Controls.Count > 0 Then  
                For Each Ctrl As WebControl In Page.Controls  
                    If Ctrl.GetType() Is (GetType(Telerik.Cms.Engine.WebControls.GenericContent)) Then  
                        Dim webControlGC As Telerik.Cms.Engine.WebControls.GenericContent = TryCast(Ctrl, Telerik.Cms.Engine.WebControls.GenericContent)  
                        If Not webControlGC Is Nothing Then  
                            webControlGC.Content.ToString()  
                            Exit For  
                        End If  
                    End If  
                Next  
     
            End If  
       
            Me.MasterPageFile = "Site.Master" 
             'Now switch the content from it's original placeholder to one that is in site.master  
     
        End Sub  
     
        Private Sub RenderPopup()  
            Me.MasterPageFile = "" 
        End Sub  
     

    Am I going about this the right way?

    Any help is appreciated.

    Thanks Jodie
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Dec 2009
    Link to this post
    Hello Jodie,

    You can do this, but in your code you need to get the masterpage ContentPalceholder by id and there move the content you have. You can also loop through ContentPlaceHolder ControlsCollection - ContentPlaceHolder1.Controls

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered