Copied to clipboard

Flag this post as spam?

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


  • Bijesh Tank 184 posts 411 karma points
    Aug 18, 2016 @ 08:47
    Bijesh Tank
    0

    Capture current page name on submission

    Hi,

    I have a form that is reused on quite a few pages and we would like to capture the page where the form submission has come from, and then show the entry (in the backoffice) with the page name. Is this possible?

    I was thinking about including a hidden field as part of the form as a new question in the backoffice but then how can I pass the current page name to that hidden field?

    Thanks, B.

  • Warren Buckley 2063 posts 4428 karma points MVP 6x admin hq c-trib
    Aug 18, 2016 @ 14:26
    Warren Buckley
    101

    Hi Bijesh,
    We log the node ID of the page for the submission, but currently do not display the page name or URL that it was posted from.

    You could use a hidden field as you describe and use a default value in the field along with the Forms syntax. Hopefully this should be enough to achieve what you need to do.

    [@queryParam]
    [%sessionValue]
    [^dictionaryItem]
    [#nodeProperty]
    [$nodePropertyRecursive]
    

    Thanks,
    Warren :)

  • Bijesh Tank 184 posts 411 karma points
    Aug 18, 2016 @ 15:10
    Bijesh Tank
    0

    Thanks for the pointer Warren!

    Works like a charm :)

  • Mads Sørensen 180 posts 394 karma points
    Sep 18, 2017 @ 17:52
    Mads Sørensen
    0

    Hi Warren - is it possible for you to explain this a bit?

    I've have tried ti paste this into the default value field but with no luck:

    [#Model.Content.Name]

    [#CurrentPage.Name]

    But that dosent seem to do the job.

    What am I doing wrong?enter image description here

  • Levi Patel 3 posts 72 karma points
    Oct 12, 2017 @ 21:49
    Levi Patel
    0

    Hi Mads,

    I also couldn't get it to work by using CurrentPage, however it was successful when I used a node property name.

    For example: [#articleName]

    Hidden field default value

    You can find the property name by looking at the document type. It is displayed next to the padlock icon above the property/field name, as shown here:

    Document type

  • Martin 256 posts 625 karma points
    Nov 22, 2017 @ 11:25
    Martin
    0

    Hi Mads,

    Did you get the hidden field to return the page name?

    *Edit - I've figured it out and used the [#nodeProperty] in the hidden field. Replacing [#nodeProperty] with [#pageName]

  • Mads Sørensen 180 posts 394 karma points
    Nov 22, 2017 @ 13:01
    Mads Sørensen
    0

    Hey Martin - i figured it out - But thanks :D

  • jonok 246 posts 439 karma points
    Jun 07, 2017 @ 23:09
    jonok
    0

    I'm currently trying to do this in Umbraco Forms - but I don't understand Warren's instructions. Is there an easy way to display the page name in the email subject or body? This is important, as my client wants to know which pages are being used to submit a single form that appears throughout the website.

  • Martin 256 posts 625 karma points
    Jul 11, 2017 @ 13:10
    Martin
    0

    Hi, @Bijesh & @jonok, did you get the page name returned in the form entry?

    Thanks M

  • jonok 246 posts 439 karma points
    Jul 11, 2017 @ 23:00
    jonok
    0

    Hi Martin, I ended up getting it to work by doing the following (it's a bit convoluted)...

    Add a metatag to the head of each page, and insert the page name into the 'content' of the metatag:

    <meta name="page.name" content="@Model.Content.Name">
    

    Then in Umbraco Forms, I include a question of type 'hidden' in each of the forms, and I give the question a title of 'Page Name'.

    Then in the footer of each page, I use jquery to get the page name from the metatag and insert it into the hidden form input:

    if($('.pagename').length) {
          var pageName = $("meta[name='page.name']").attr('content');
          $(".pagename input").val(pageName);
    }
    

    Now when the form is submitted, the page name is included in the email along with the rest of the form data.

    It's not the most elegant solution, but it works - which is the important thing.

  • Steve Morgan 957 posts 2966 karma points c-trib
    18 days ago
    Steve Morgan
    0

    Sorry to drag this up but I've sorted this before and couldn't find the answer and this one scores highly on Google.. I've even found my own posts answering this question!

    The hidden (not in documentation?) default values are:

    • [#pageName] - gets node name
    • [#pageId] - gets the node ID
    • Question - how to get the URL?
Please Sign in or register to post replies

Write your reply to:

Draft