Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to not include something in Application.cfm

Status
Not open for further replies.

mike2277

Programmer
Mar 25, 2002
54
US
Hi,
I am developing an application that can be used by more than one client.

In my top level Application.cfm file I am using:

<cfinclude template=&quot;globals.cfm&quot;> to pull out the client's preferred color scheme, banners, images, etc. from a PreferencesInfo table.

The globals page requires #url.clientID# in order to get the right row from the PreferencesInfo table. So #url.ClientID# needs to be passed on all pages (not a problem because it's a small application).

My problem is I'm using a custom tag for a calendar tool on an insert user form and I can't pass #url.ClientID# when calling up the custom tag (just a pop-up window date selector):

<CFMODULE
Template=&quot;../customTags/intelliCalendar/intelliCalendar.cfm&quot;
FieldName=&quot;DateOfBirth&quot;
FormName=&quot;userAdd&quot;>

Since this is a pop-up window I don't even need to pass the url.ClientID for the purposes of my form but since I've included global.cfm in my top level application file it's requesting url.clientID for every page I call (including for the pop-up window).

Is there some way to NOT include &quot;globals.cfm&quot; if I'm using the calendar custom tag?

I've tried in Application.cfm:

<cfif IsDefined(&quot;attributes.userAdd&quot;)>
<cfelse>
<cfinclude template=&quot;globals.cfm&quot;>
</cfif>

but that didn't work (it's not recognizing attributes.userAdd).

I've also tried to append the url.client onto

<CFMODULE
Template=&quot;../customTags/intelliCalendar/intelliCalendar.cfm?ClientID=#url.ClientID#&quot;

but that didn't work either.


Any help you could provide would be appreciated! I'll try any suggestion at this point.

Mike






 
How about:
Code:
<cfif IsDefined(&quot;URL.ClientID&quot;)>
  <cfinclude template=&quot;globals.cfm&quot;>
</cfif>
in your application.cfm file.

-Tek
 
You may want to try this:

<CFIF GetFileFromPath(GetTemplatePath()) NEQ &quot;intelliCalendar.cfm&quot;>
<cfinclude template=&quot;globals.cfm&quot;>
</cfif>

This will tell it to include the template on every page EXCEPT the calendar page. You may have to play with the path for the intelliCalendar.cfm page, but you get the idea.

If you try to do the IsDefined for the Url.ClientID variable, what's going to happen if someone tampers with the URL and takes the variable out?

It's always better to let CF do the thinking and not rely on what a user may or may not put in (or tamper with). This way CF knows exactly what it's supposed to do and when, and you won't have to worry about something happening when it's not supposed to (like when a url variable is missing).

Hope this helps!
 
There is no risk of something bad happening here. If the user wants to fool around with the URL variables, they will simply not get their preferences displayed. This is not the fault of the application. By your logic, if I go to amazon.com and change the product id in the URL to something non-existent, the product I want will not appear. What's the point? If you are worried about the user changing the URL variable in this case, store the clientid in a cookie, or rely on CF's session management or client management.

The problem with your technique is it could get unmanageable, fast. What if I have 25 pop-up pages I don't want the global settings to appear on; am I going to have to create an array with all the pages' names to check all those pages? That is neither efficient nor acceptable to someone who has to manage the application; it's just an ad-hoc approach.

With my suggestion, the app fails gracefully where preferences are concerned; with your's it works just for the calendar page. When the user wants to add another page which doesn't need to take into account the global preferences, he has to remember to go back and do another check for the appropriate page name. Also, what if you have 4 index.cfm pages that you don't want preferences displayed on? Now you are in a situation where you have to compare full paths to see if the globals file should be included. This is NOT a way to design an application.

-Tek
 
Thanks for the suggestions!

I tried <cfif IsDefined(&quot;URL.ClientID&quot;)>
<cfinclude template=&quot;globals.cfm&quot;>
</cfif>


and it worked just great!

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top