The UDF below returns the name of the current page (including the .cfm  
extension).  When called from inside of a custom tag, it will return  
the name of the calling page (at least it did during my one quick test):

<cfscript>
     function getCurrentPageName()
     {
         var pageContext = getPageContext();
         var req = pageContext.getRequest();
         var path = req.getServletPath();
         return listGetAt(path,listLen(path)+1, "/");
     }
</cfscript>

Is this what you were looking for?

Also, another solution is simply to pass the page name in as an  
attribute to the custom tag.  It's not as elegant, but it does leave  
you some flexibility.  For instance, it allows you to "trick" your  
custom tag into thinking it is being called by another page, which  
could possible prove useful, depending on your circumstance.

Happy holidays.

Christian

On Monday, December 23, 2002, at 09:01 PM, Matthew Walker wrote:

> Is there a way under cfmx to retrieve the name of the template that
> calls a custom tag? I've tried this, which works although it seems
> inelegant.
>
> <cftry>
>       <cfthrow>
>       <cfcatch>
>               <cfif arrayLen(cfcatch.tagcontext) gt 1>
>                       <cfset parentTemplate =
> cfcatch.tagcontext[2].template>
>               <cfelse>
>                       <cfset parentTemplate = "">
>               </cfif>
>       </cfcatch>
> </cftry>
>
> <cfoutput>The template that called this tag was:
> #parentTemplate#</cfoutput>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to