protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            if ( !Page.IsPostBack )
            {
                int? adId = PageParameter( "Ad" ).AsInteger();
                if ( adId.HasValue )
                {
                    MarketingCampaignAd ad = new MarketingCampaignAdService( new RockContext() ).Get( adId.Value );
                    if ( ad != null )
                    {
                        // TODO: Still need to add checks for Ad approval, ad type, start/end date etc.

                        var dict = ad.ToLiquid() as Dictionary<string, object>;

                        string layout = GetAttributeValue( "Layout" );
                        string content = layout.ResolveMergeFields( dict );

                        // check for errors
                        if (content.Contains("No such template"))
                        {
                            // get template name
                            Match match = Regex.Match(GetAttributeValue("Template"), @"'([^']*)");
                            if (match.Success)
                            {
                                content = String.Format("<div class='alert alert-warning'><h4>Warning</h4>Could not find the template _{1}.liquid in {0}.</div>", ResolveRockUrl("~~/Assets/Liquid"), match.Groups[1].Value);
                            }
                            else
                            {
                                content = "<div class='alert alert-warning'><h4>Warning</h4>Unable to parse the template name from settings.</div>";
                            }
                        }

                        if (content.Contains("error"))
                        {
                            content = "<div class='alert alert-warning'><h4>Warning</h4>" + content + "</div>";
                        }

                        phDetails.Controls.Add( new LiteralControl( content ) );
                    }
                }
            }
        }
示例#2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                int?adId = PageParameter("Ad").AsInteger();
                if (adId.HasValue)
                {
                    MarketingCampaignAd ad = new MarketingCampaignAdService(new RockContext()).Get(adId.Value);
                    if (ad != null)
                    {
                        // TODO: Still need to add checks for Ad approval, ad type, start/end date etc.

                        var dict = ad.ToLiquid() as Dictionary <string, object>;

                        string layout  = GetAttributeValue("Layout");
                        string content = layout.ResolveMergeFields(dict);

                        // check for errors
                        if (content.Contains("No such template"))
                        {
                            // get template name
                            Match match = Regex.Match(GetAttributeValue("Template"), @"'([^']*)");
                            if (match.Success)
                            {
                                content = String.Format("<div class='alert alert-warning'><h4>Warning</h4>Could not find the template _{1}.liquid in {0}.</div>", ResolveRockUrl("~~/Assets/Liquid"), match.Groups[1].Value);
                            }
                            else
                            {
                                content = "<div class='alert alert-warning'><h4>Warning</h4>Unable to parse the template name from settings.</div>";
                            }
                        }

                        if (content.Contains("error"))
                        {
                            content = "<div class='alert alert-warning'><h4>Warning</h4>" + content + "</div>";
                        }

                        phDetails.Controls.Add(new LiteralControl(content));
                    }
                }
            }
        }
示例#3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                int?adId = PageParameter("Ad").AsInteger();
                if (adId.HasValue)
                {
                    MarketingCampaignAd ad = new MarketingCampaignAdService().Get(adId.Value);
                    if (ad != null)
                    {
                        // TODO: Still need to add checks for Ad approval, ad type, start/end date etc.

                        var dict = ad.ToLiquid() as Dictionary <string, object>;

                        string layout       = GetAttributeValue("Layout");
                        string mergedLayout = layout.ResolveMergeFields(dict);

                        phDetails.Controls.Add(new LiteralControl(mergedLayout));
                    }
                }
            }
        }