7 Replies Latest reply on Aug 20, 2010 4:04 AM by webmonkeymagic

    Get current path of page

      I'm making use of the Facebook Like function and for it to work properly I need to enter the URL of the current page being displayed. I tried using:

      <!--$ssGetServerRelativeUrl(nodeId, siteId)-->

      that I found from a different post, but nothing is showing up on the page. Any suggestions?

      In advance, thanks!

      Edited by: Trevor B on Aug 17, 2010 10:27 AM

      Edited by: Trevor B on Aug 17, 2010 10:28 AM
        • 1. Re: Get current path of page
          maybe too obvious here, but are you storing it in a variable on printing it to the screen?

          • 2. Re: Get current path of page
            LOL - maybe obvious to you, but I'm so green at this! ;-)

            My plan is to create a Region Template with the html embed code from facebook - I'm assuming that means I would be printing it to the screen. However, I'll take any info you can offer (how I actually end up using it might change in the end).

            • 3. Re: Get current path of page
              Try this:


              looks like you have the siteId and nodeId around the wrong way.
              • 4. Re: Get current path of page
                That's great - thanks! :-)

                That seems to work fine on primary pages, but secondary pages still points back to the primary page - is there something that will work regardless what page it's on?

                How would I include the path of the server. For example, if the page I'm on is:


                how would I generate the whole path including the server?

                Edited by: Trevor B on Aug 18, 2010 7:20 AM
                • 5. Re: Get current path of page
                  Oh....well in that case you will need to do something like this:

                  http://[!--$SERVER_NAME--]/[!--$ssGetServerRelativeUrl(siteId,nodeId)--][!--$if isSecondaryPage eq 1--][!--$region1--][!--$endif--]

                  region1 would be the region for the main content, you may have renamed it to something else.

                  There is another way to do this which I think would be easier, if you append ?IsJava=1 to the end of the URL you will see a page that will display the local data properties.

                  One of the variables you want to look for is *'siteRelativeUrl'* if you use this there will be no need to check if the page you are on is a secondary page.
                  It would look something like this:

                  • 6. Re: Get current path of page
                    Outstanding! Thank you! :-)
                    • 7. Re: Get current path of page
                      ssGetServerRelativeUrl() will include the primary page file name, if assigned. Don't use it for building paths to secondary pages because you will get this:

                      Use this one instead, it omits the file name:

                      Also, you can simply return the current URL without having to recalculate it. Use this: