How Can I grab the current page's URL?

matthew.wren's Avatar

matthew.wren

26 May, 2016 08:09 PM

I'm working on an email I'm creating a section of the email that'll say "View in Browser" and I want a velocity script to grab the page's URL...how can I do this? Index block or can it be done with just a script?

  1. 1 Posted by Ryan Griffith on 26 May, 2016 08:17 PM

    Ryan Griffith's Avatar

    Hi Matthew,

    If the page is within a different Site than the email, you can simply link to the page using it's link value (i.e. site://path/to/page). The cross-site link will have the Site's URL appended onto the front of the page's path.

    If the page is within the same Site, there is currently no way to create a fully qualified link to the page without manually appending the domain information onto the front of the page's path. You will also need to configure the "email page" to Maintain Absolute Links so the generated path to the page is not relative.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by matthew.wren on 27 May, 2016 01:11 PM

    matthew.wren's Avatar

    Hey Ryan,

    Thanks for the help! The maintain absolute links will be crucial since it's an email.

    I used a very simplified index calling block to solve my issue.

    I attached the settings I used for my index block and here's the results:

    <?xml version="1.0" encoding="UTF-8"?>
    <system-index-block name="current page" type="folder" current-time="1464354465130">
        <calling-page>
            <system-page id="e475086f86c604b2730f35c70a99447b" current="true">
                <name>version3</name>
                <path>/emails/2016/06/version3</path>
                <site>Undergraduate Admissions</site>
                <link>site://Undergraduate Admissions/emails/2016/06/version3</link>
            </system-page>
        </calling-page>
    </system-index-block>
    

    So this is my snippet of velocity to grab the link:

    <a href="${_XPathTool.selectSingleNode( $contentRoot, '/system-index-block/calling-page/system-page/link').value}">View Email in Browser</a>
    

    I think this is the simplest way, at least for my purposes, to alway have the email's link.

  3. Support Staff 3 Posted by Tim on 27 May, 2016 01:26 PM

    Tim's Avatar

    Hey Matthew,

    Glad to hear that Ryan was able to help out. I appreciate you sharing what worked for you so that others on this forum can get ideas if they ever need to accomplish something similar to this.

    Have a good one!

  4. Tim closed this discussion on 27 May, 2016 01:26 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac