|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Auto-append params
I have files in a subdir under an application.cfc.Darren Houle 09/06/08 11:54 P > I have files in a subdir under an application.cfc.Dave Watts 09/07/08 12:03 A Thanks Dave, I was kinda thinking the same thing... you just saved me some work!Darren Houle 09/07/08 12:09 A I have files in a subdir under an application.cfc. I'd like to automatically append a specific myvar=somevalue to every hyperlink on these pages. Is there a way I can use onRequest and regular expressions to re-write paths before they're output back to the browser? For instance, in a template I have: <a href="myfile.cfm">click here</a> but after parsing through onRequest (or something similar) it would look like: <a href="myfile.cfm?myvar=somevalue">click here</a> And I wouldn't have to remember to code that into every hyperlink on every page myself. The parser/re-writer should add the ? if it's not there and keep it if it is, ignore other params if they exist, add an & if needed, etc. Anyone know of such thing out there? In case you're wondering why, I'm following Philip Chalmers suggestion (http://coldfusion.sys-con.com/node/41749) about adding random numbers to url params and form actions so proxy servers never cache dynamic pages. Thanks! > I have files in a subdir under an application.cfc. > > I'd like to automatically append a specific myvar=somevalue > to every hyperlink on these pages. Is there a way I can use > onRequest and regular expressions to re-write paths before > they're output back to the browser? Yes, you can. You'd have something like this: <cffunction name="onRequest"> <cfargument name="targetPage"> <cfsavecontent var="page"> <cfinclude template="#Arguments.targetPage#"> </cfsavecontent> <!--- your regex stuff goes here ---> <cfoutput>#page#</cfoutput> </cffunction> Alternatively, you could append data to links with JavaScript. This is very easy to do, since all the links are in the document.links array. This would perform better, but would obviously only work for clients that have JavaScript enabled. > In case you're wondering why, I'm following Philip Chalmers > suggestion (http://coldfusion.sys-con.com/node/41749) about > adding random numbers to url params and form actions so proxy > servers never cache dynamic pages. I don't recommend you do this, actually. While it may have been a problem in 2002 when that article was written, it really isn't a common problem today. For that matter, I don't think it was all that common a problem in 2002. But anyway, nowadays, proxy servers tend to be well-behaved; if you don't want a file to be cached, there are all sorts of META tags you can embed in the page to instruct proxies. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! Thanks Dave, I was kinda thinking the same thing... you just saved me some work! Darren ----- Excess quoted text cut - see Original Post for more -----
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||