Skip navigation
Currently Being Moderated

How to recognize a page name from the URL

Dec 8, 2011 10:12 AM

Hello,

 

Is there a way to capture the name of a file in Application.cfc based on a URL?  So, if the URL happens to be www.somelink.toys.cfm, I would like Application.cfc to indicate to the user the the name of the page is "toys.cfm".

 

Thanks so much!

Jenn

 
Replies
  • Currently Being Moderated
    Dec 8, 2011 10:46 AM   in reply to jenn

    Anything to do with URLs will be in the CGI scope, dump that out and see what you get

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2011 12:56 PM   in reply to jenn

    jenn wrote:

     

    Hello,

     

    Is there a way to capture the name of a file in Application.cfc based on a URL?  So, if the URL happens to be www.somelink.toys.cfm, I would like Application.cfc to indicate to the user the the name of the page is "toys.cfm".

    You could do that at the level of Application.cfc or at the level of the page itself.

     

    1st case: doing it at the level of Application.cfc

     

    Declare the current path as a request variable in onRequestStart, as follows

     

    <cffunction name="onRequestStart">

    <cfargument name = "targetPage" type="String" required="true">

    <cfset request.page = arguments.targetPage>

    </cffunction>

     

    Then access the file name as follows in an arbitrary page.

     

    testpage.cfm

    <cfoutput>#listLast(request.page, "\")#</cfoutput>

     

     

    2nd case: doing it directly, via the page itself

     

    testpage.cfm

    <cfoutput>#listLast(getBaseTemplatePath(), "\")#</cfoutput>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points