Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike Chambers 636 posts 1253 karma points c-trib
    Jan 14, 2013 @ 19:03
    Mike Chambers
    0

    send email workflow.. anyway to get the referring page to the form page?

    So a little more explaination we have a link on a product page to email the sales engineer...

    so if a user then ends up at the contour form and sends an email, we'd like to say they came from this product page...

    as the workflow is outside of the page context.. any ideas on how we can retrieve the referer?

    in a standard form scenario... we'd be using

    if (!Page.IsPostBack)
                {
                    try
                    {
                        // try and store the referer so we can indicate how the user came to this form.
                        ViewState.Add("Referrer", System.Web.HttpContext.Current.Request.UrlReferrer.ToString());
                    }
                    catch { }
    }

    and then reference the viewstate later.

  • Comment author was deleted

    Jan 15, 2013 @ 09:59

    Hi Mike are you customizing the code, I think the record holds the id of the page it was posted on so you should be able to use that :)

  • Mike Chambers 636 posts 1253 karma points c-trib
    Jan 15, 2013 @ 10:21
    Mike Chambers
    0

    Yep custom code for workflow and updated renderform.ascx and renderform.cs (for new fieldtypes - which just discovered need to be replicated somehow on the mvc side for preview to work as get errors of no fieldtype specified)... 

    The partial view '/umbraco/plugins/umbracoContour/Views/Fieldtype.textfieldwithcompare.cshtml' was not found or no view engine supports the searched locations. The following locations were searched: /umbraco/plugins/umbracoContour/Views/Fieldtype.textfieldwithcompare.cshtml

    Can I make a request for new documentation as the 1.1 pdf is a little behind??? and maybe also for you to release the source code for renderform.cs??? Also did the customisable templates from v5 (where you put cshtml files in the app_data/plugins/countour/guid/renderform.cshtml) make it back into v3 and is that just a mvc thing or maybe webform support too? 

    And yep already use the record id, but that just gives me the page that the form is on... not the page that the user was on immediately before the form... eg the refering page to the form page...

    Only way I can see is to perhaps have a hidden field, and set the value on page load for the referer, then I can access that hidden field via the record in the workflow?

    Was just asking though if any way to get the System.Web.Page context from the custom workflow class??

  • Comment author was deleted

    Jan 15, 2013 @ 13:23

    Sorry misunderstood the question have you tried if System.Web.HttpContext.Current.Request.UrlReferrer contains anything?

  • Mike Chambers 636 posts 1253 karma points c-trib
    Jan 17, 2013 @ 18:33
    Mike Chambers
    0

    Ended up adding a hidden field and overriding the OnLoad or renderForm

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
    
    
        if (!Page.IsPostBack)
        {
            try
            {
                // try and store the referer so we can indicate how the user came to this form.
                ViewState.Add("Referrer", System.Web.HttpContext.Current.Request.UrlReferrer.ToString());
            }
            catch { }
        }
    
    
    
    
       FormStorage fs = new FormStorage();
       var form = fs.GetForm(new Guid(this.FormGuid));
    
        var fields = form.AllFields;
        Umbraco.Forms.Core.Field refer = fields.Find(x => x.Caption == "Referring Page");
    
        Control ctrlReferer = FindControlRecursive(rpFieldsets, refer.Id.ToString().Replace('-', '_'));
        try
        {
            System.Web.UI.WebControls.HiddenField hf = (System.Web.UI.WebControls.HiddenField)ctrlReferer.Controls[0];
            hf.Value = ViewState["Referrer"].ToString();                        
        }
        catch { }
    }

    Seems a little hacky... would you have any other thoughts?

    Maybe a nice to have extension to contour... could be having the default value of a hidden field call a method from an assembly? that wasy you get the resultant call also logged as a record item for the backend to view.

  • Comment author was deleted

    Jan 17, 2013 @ 19:26

    Glad you found a solution! Yup plan is to make it possible to extend the bracket syntax so it's possible to plugin custom stuff 

    http://issues.umbraco.org/issue/CON-54

Please Sign in or register to post replies

Write your reply to:

Draft