Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 5061 posts 15523 karma points MVP admin hq
    May 31, 2010 @ 09:23
    Sebastiaan Janssen
    0

    Don't display form based on cookie value

    I'm trying to create a form in Contour which is a simple poll. I want to be able to not display the form when somebody has already voted. I plan to store a cookie and use it to save the form's ID and whether the user has already voted. I know this is not very tamper proof, but it's fine for the needs of this project.

    How do I detect the presence and content of the cookie and tell Contour not to display the form, but the results of the poll? I don't know where to start, so any suggestion is welcome.

  • Harald Ulriksen 207 posts 249 karma points
    Jun 01, 2010 @ 10:41
    Harald Ulriksen
    1

    Hi Sebeastiaan,

     

    you can controll this by either inheriting the user control used to render the form or wrap that user control in your own. Either way you will have to do some coding.

    The Farm has a blog post on how to inherit the RenderForm user control. If you just wish to wrap it you can do it like this:

    1. In your your vs project create a folder called umbracoContour in the folder where you have user controls.

    2. Copy Renderform.ascx to the newly created folder.

    3. Reference Umbraco.Forms.Core and Umbraco.Forms.UI.

    4. Create a new user control and add the RenderForm to it. You can now controll render form from your own user control. In the on load you can validate your cookie and control Contour display.


    Hth,
    Harald.

  • Sebastiaan Janssen 5061 posts 15523 karma points MVP admin hq
    Jun 01, 2010 @ 12:14
    Sebastiaan Janssen
    0

    Hey Harald, thanks for the reply!

    I'm now halfway there.. Could you also tell me how I would set the cookie after the form has been successfully submitted? 

    By the way, this does also mean that RenderForm is now under my control for each and every Contour form I create, right? So how should I filter out that I only want to hide the poll form and not the contact form and the newsletter subscribe form (for example)?

  • Harald Ulriksen 207 posts 249 karma points
    Jun 01, 2010 @ 14:06
    Harald Ulriksen
    0

    You can set the cookie in an custom workflow. The event args on workflow type contains the httpcontext which should get you there.

    That depends on how you do it. If you wrap it in your own user control you have 2 macros, one for the original form display and one macro for the wrapped one. Guess the same can apply to the inherit solution if you copy the renderform.ascx to a new file and modify the copy.

    Just spotted that I forgot the link to The Farm blog post in the previous reply. The blog post on inheriting from Contour RenderForm can be found here http://farmcode.org/post/2010/03/26/Regionalizing-validation-messages-and-regex-in-Umbraco-Contour.aspx

    Hth,
    Harald

  • Harald Ulriksen 207 posts 249 karma points
    Jun 01, 2010 @ 22:02
    Harald Ulriksen
    0

    Wrote a blog post on it as well

Please Sign in or register to post replies

Write your reply to:

Draft