application.cfc subdirectories and links

2009-04-17 Thread Elizabeth Meyer

I have used the Application.cfc onRequestStart and onRequestEnd for the layout 
of 
my site, i.e. common header, mainnavigation and footer on all pages.

Now the problem comes in where I have some files in a subdirectory: (The 
application.cfc is only in the root directory)

the main navigation (siteroot\mainnav.cfm) is included in the application.cfc 
onRequestStart, but if this is called from the siteroot\subdir\somefile.cfm the 
links points to (e.g.) siteroot\subdir\aboutUs.cfm instead of 
siteroot\aboutUs.cfm

Is there a way I can reference the links relative to the included template 
(siteroot\mainnav.cfm) instead of relative to the page I am on?

I don't want to use absolute links, because that is a lot of links I will have 
to go and update... 

Thanks! 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321775
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: application.cfc subdirectories and links

2009-04-17 Thread Ben Nadel

Liz,

This is not a great solution, but you could put a dynamic Base tag in the
head:

Main directory:

base href=./ /

Sub directory:

base href=../ /

I think that would work as a stop-gap.

-- 
Ben Nadel
Adobe Community Expert
Adobe Certified Advanced ColdFusion Developer
Manager New York ColdFusion User Group
http://www.bennadel.com

Need ColdFusion Help?
http://www.bennadel.com/Ask-Ben


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321776
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: application.cfc subdirectories and links

2009-04-17 Thread Peter Boughton

Create a mapping to the siteroot, and do cfinclude 
template=/siterootmapping/afile.cfm/ ? 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321777
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: application.cfc subdirectories and links

2009-04-17 Thread Adrian Moreno

IMO, your best option is going to be setting your header, footer, etc. links to 
absolute paths. 

Meaning if your application root is www.mysite.com, then all of your primary 
links need to point to /aboutUs.cfm. The ensures that no matter how deep you 
are in the site, that link will always point to www.mysite.com/aboutUs.cfm.

Most every other option is going to involve parsing the URL and figuring out 
where you are relative to your root and that's going to be more of a pain than 
resetting all those links.

If you want, you can set an application variable as a placeholder for your 
application roor, i.e. cfset application.siteRoot = /. Then all of your 
links will look like 

[a href=#application.siteRoot#/aboutUs.cfm]About Us[/a}

If your site root changes, just update the application variable.

HTH, 

Adrian



 I have used the Application.cfc onRequestStart and onRequestEnd for 
 the layout of 
 my site, i.e. common header, mainnavigation and footer on all pages.
 
 Now the problem comes in where I have some files in a subdirectory: 
 (The 
 application.cfc is only in the root directory)
 
 the main navigation (siteroot\mainnav.cfm) is included in the 
 application.cfc onRequestStart, but if this is called from the 
 siteroot\subdir\somefile.cfm the links points to (e.g.) 
 siteroot\subdir\aboutUs.cfm instead of siteroot\aboutUs.cfm
 
 Is there a way I can reference the links relative to the included 
 template (siteroot\mainnav.cfm) instead of relative to the page I am 
 on?
 
 I don't want to use absolute links, because that is a lot of links I 
 will have to go and update... 
 
 Thanks! 


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321778
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4