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 192 posts 420 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 2106 posts 4836 karma points MVP ∞ 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 192 posts 420 karma points
    Aug 18, 2016 @ 15:10
    Bijesh Tank
    0

    Thanks for the pointer Warren!

    Works like a charm :)

  • Mads Sørensen 188 posts 433 karma points
    Sep 18, 2017 @ 17:52
    Mads Sørensen
    1

    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 73 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 278 posts 662 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 188 posts 433 karma points
    Nov 22, 2017 @ 13:01
    Mads Sørensen
    0

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

  • jonok 297 posts 657 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 278 posts 662 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 297 posts 657 karma points
    Jul 11, 2017 @ 23:00
    jonok
    1

    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 1345 posts 4452 karma points c-trib
    Jun 06, 2018 @ 10:43
    Steve Morgan
    1

    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?
  • Ulrik Ricco Hansen 6 posts 25 karma points
    Oct 10, 2018 @ 11:15
    Ulrik Ricco Hansen
    0

    just replace [#pageId] with [#pageID]

  • Shawn Calvert 31 posts 195 karma points
    Aug 08, 2018 @ 19:07
    Shawn Calvert
    0

    I'm also trying to figure out what the Umbraco Forms magic string for the current page URL would be -- I think I've tried all the obvious variations, but doesn't seem to work.

    Anyone know? Ideally, I'd like to avoid a js solution if possible; the other magic string fields worked like a charm.

    thank you

  • Shawn Calvert 31 posts 195 karma points
    Aug 08, 2018 @ 19:35
    Shawn Calvert
    3

    ok, I feel dumb -- it's just

    [@Url]

    to get the page segment.

  • Brita Curum 9 posts 79 karma points
    Oct 17, 2019 @ 08:38
    Brita Curum
    0

    Hi,

    [@pageID] or [#pageID] does not seem to work on Umbraco 8.

    Anyone knows how to set it for Umbraco 8?

    Many thanks.

  • Chris Ashton 57 posts 89 karma points
    Nov 27, 2022 @ 23:12
    Chris Ashton
    1

    For future me... this now appears to be well documented on Our Umbraco's UmbracoForms > Developer > Magic String section:

    https://our.umbraco.com/documentation/Add-ons/UmbracoForms/Developer/Magic-Strings/

Please Sign in or register to post replies

Write your reply to:

Draft