-
1. Re: Using Multiple Values with CFSET
Dan Bracuk Jan 29, 2011 8:41 AM (in response to OgreOne)For the approach you are trying, the ListFind function will help you.
Your approach has a weakness. Storing data in source code means you have to edit your source code, possibly in more than one place, in order to change your data. This means it takes a programmer to do it. Another approach is to store your data outside your source code (database, text file, whatever). This will enable you to delegate the data maintenance.
Based on your post, it looks like a database is a good option. This will give you the opportunity to group your people which will lead to simpler code. Your conditional logic can be based on groups rather than individual people which will lead to less code.
-
2. Re: Using Multiple Values with CFSET
OgreOne Jan 29, 2011 1:19 PM (in response to Dan Bracuk)That does help. Thanks. The issue is I do not want to add another field to the dat
abase. I already have username, password and role. I could use roles, but the users are all part of different roles and other users of the same roles are not allowed. So it would seem I would need another field specifically for a sub group. Was hoping to do it another way.
I am intriqued with the text file method. How does that work?
Thanks.
-
3. Re: Using Multiple Values with CFSET
OgreOne Jan 29, 2011 1:23 PM (in response to Dan Bracuk)How does the ListFind work for what I am using? Sample code?
Thanks.
-
4. Re: Using Multiple Values with CFSET
Dan Bracuk Jan 29, 2011 4:21 PM (in response to OgreOne)To find sample code for any cf function, google "coldfusion name of function". Look for the 1st offering from adobe. It will be the page from the CFML Reference Manual and will include an example.
-
5. Re: Using Multiple Values with CFSET
OgreOne Jan 29, 2011 5:06 PM (in response to Dan Bracuk)Wow. Not very helpful. When did persons on Adobe forums become so unhelpful
ans unkind? Might as well join the IT brigade or one of many Mopar owners.
-
6. Re: Using Multiple Values with CFSET
BKBK Jan 30, 2011 1:22 AM (in response to OgreOne)OgreOne wrote:
Currently using CF7 to develop for server.
Using multiple (a lot) <cfif> statements on page to hide/show based on username credentials.
My curernt code for this is:
<cfif (MM_Session.Username EQ 'name1' OR MM_Session.Username EQ 'name2' OR MM_Session.Username EQ 'name3')>Show me something</cfif>
The issue is that to add/change/delete a name, I have to do this 15 times. I can always use Find/Replace but I thought I could set something up in the Application file to better manage. What I have come up with is this:
In the Application, I inserted:
<cfset theadmin = "name1, name2, name3">
On the other page:
<cfif (MM_Session.Username EQ #theadmin#)>Show me something</cfif>
Of course, it did not work. I know there must need be an array, but I do not know how to do this with cfset and everything I found in searches and documentation doesn't seem to work either. I was hoping to create a list of usernames in the application so I can quickly add/change/delete users one time.
Any thoughts or help would be great! Thanks in advance!
First of all, it is important that your Application.cfm file implements the cfaplication tag. At least something like this will do:
<cfapplication name = "myApp" applicationTimeout = "#CreateTimeSpan(1, 0, 0, 0)#" sessionManagement = "Yes" sessionTimeout = "#CreateTimeSpan(0, 0, 20, 0)#" >
Then, put this in the Application.cfm file:<cfset application.adminList = "name1,name2,name3"><!--- No spaces in between!--->
It makes the adminList variable available to every page in your application. You can now do the following check on any page:
<cfif listFindNoCase(application.adminList, MM_Session.Username) GT 0>Show me something</cfif>
-
7. Re: Using Multiple Values with CFSET
Owain North Jan 30, 2011 7:33 PM (in response to OgreOne)Wow. Not very helpful. When did persons on Adobe forums become so unhelpful
ans unkind?
Excuse me? Probably one of the single rudest comments I've ever seen posted on here. Everyone on here does so for nothing, to give something back to the Community and to point people in the right direction. There is a reasonably small number of regular posters in the CF forums, all of whom have their own jobs to do.We are not here to do your job for you. You have been given ample hints and tips, but you evidently can't even be arsed to Google things for yourself. Don't even get me started on this:
How does the ListFind work for what I am using? Sample code?
All the documentation you need is online. Your attitude to people trying to give you free help is quite frankly appalling. If you want someone to do your work for you then you should pay someone to do it rather than relying on people you don't even know doing it for free in their spare time.
-
8. Re: Using Multiple Values with CFSET
Dan Bracuk Jan 30, 2011 7:25 AM (in response to OgreOne)You might want to re-think your reluctance to use the roles you are storing in your db. That's the path that appears to be most promising.
The text file method would use the same general principles as a database. The details would be different. Using it when you already have a database would mean that you would have two sets of data to maintain. Bad idea.
-
9. Re: Using Multiple Values with CFSET
OgreOne Jan 30, 2011 4:14 PM (in response to BKBK)Awsome! This works and saves me TONS of recoding..Thanks!
-
10. Re: Using Multiple Values with CFSET
OgreOne Jan 30, 2011 4:24 PM (in response to Owain North)I never stated I wanted someone to do my work ("I know there must need be an array, but I do not know how to do this with cfset and everything I found in searches and documentation doesn't seem to work either."), I was just asking for a little more help than "go search for it." I had already done that and tried what I found. The forum, from what I understand are to help others who are learning or are stuck.
Thanks to BKBK's wonderful ability to share, I got it all to work. I am not the first who needed more help. If someone doesn't want to help without getting paid, they should not be on the forums in the first place. There was a time when designers and coders were glad to help and teach without anything in return. Now all anyone want s is money. I am always willing to share what I learn with others. It flatters me that someone could use the potential help I could give. Latley, it seems all have just been throwing it in the face of newbies that old dogs know the answer and the newbies don't. Like they want to take the answers to their graves. Sad really. Hope tit all changes for the better soon.
-
11. Re: Using Multiple Values with CFSET
MichaelKazlow Jan 30, 2011 7:31 PM (in response to OgreOne)@OgreOne,
Criticising someone that gives you direction and help, even if it is not the direction and help you want is not called for. It is better to say, "I've already googled for information relating to the subject and did not find the information helpful. Can someone give me more direct help."
I'm glad you got the help that you needed. When you get a chance to reread some of the advise you were given, perhaps you will find it useful at a later date.
@everyone, this thread is now closed. It has satisifed the user's need.
Michael Kazlow
Forum Host


