7 Replies Latest reply: Aug 19, 2010 11:04 PM by webmonkeymagic RSS

    Get current path of page

    778838
      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
          674493
          maybe too obvious here, but are you storing it in a variable on printing it to the screen?

          -jason
          • 2. Re: Get current path of page
            778838
            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).

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

              [!--$ssGetServerRelativeUrl(siteId,nodeId)--]

              looks like you have the siteId and nodeId around the wrong way.
              • 4. Re: Get current path of page
                778838
                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:

                http://www.mysite.com/DEV/ProgramsCourses/BA/DEV_000606

                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
                  simonsd
                  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:

                  http://[!--$SERVER_NAME--][!--$siteRelativeUrl--]
                  • 6. Re: Get current path of page
                    778838
                    Outstanding! Thank you! :-)
                    • 7. Re: Get current path of page
                      webmonkeymagic
                      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:
                      /some/path/goes/here/default.htmCONTENTID

                      Use this one instead, it omits the file name:
                      ssGetServerRelativePath()

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