Copied to clipboard

Flag this post as spam?

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


  • Luke Johnson 61 posts 80 karma points
    Oct 15, 2012 @ 19:22
    Luke Johnson
    0

    Get portion of URL path

    Is there a way to retrieve a portion of a page's URL string?

    I have academic program pages (for a College and Seminary) that need to offer a link to course offerings based on which arm of the school is offering the course: the college, seminary, or distance ed office. Some courses overlap (are offered by more than one 'arm'), so I am hoping I can retrieve "college", "seminary", or "cde" from the URL, in order to tell certain links where to go.

    Here are some link examples so you can see what I'm working with:

    1. Certificate of the Seminary
      http://briercrest.ca/seminary/programs/study.aspx?id=53&level=2

    2. Certificate of the Seminary (CDE)
      http://briercrest.ca/cde/programs/study.aspx?id=53&level=2

    At the bottom of the program page, there is a link to "View all courses". I'd like to send users to CDE's course listings when they view the program at briercrest.ca/cde, and to seminary course listings when viewing the program page at briercrest.ca/seminary. (This is necessary because CDE and the Seminary don't offer all the same courses.)

    That's the problem. To solve it, I'm hoping to be able to extract "cde" or "seminary" from the page URL so that I can tell the "View all courses" link which set of courses to link to.

    I know that the whole URL path is accessible using 

     

    http://
    

    but is there a way to grab only a specific part of the URL?

    I'm not trying to retrieve a parameter passed in the URL. That's easy enough. I'm trying to access a portion of the URL much earlier in the string.

    Any clues?

    Thanks,

    Luke


  • Luke Johnson 61 posts 80 karma points
    Oct 15, 2012 @ 19:26
    Luke Johnson
    0

    Sorry for the repeat post. I'm getting parsing errors as I try to submit this post to the forum.

  • Luke Johnson 61 posts 80 karma points
    Oct 15, 2012 @ 19:42
    Luke Johnson
    0

    Never mind. I found the solution using:

    <xsl:value-of select="$currentPage/ancestor-or-self::*[@level = 2]/@nodeName" />
Please Sign in or register to post replies

Write your reply to:

Draft