![]() |
| CF8 and arrays acting strange |
|
tri_3sports_dfw
|
Has anyone witnessed odd behavior with CF8 and Arrays? I have some code that has ran fine since CF4. Then when the server was upgraded to CF8 the site has been dead in the water.
go to www.harvestridgehoa.com to see the error live. the following code is where the error happens. <cfset idlist = ""> <cfset name_list = ""> <cfset linkids = #getcontent.link_to#> <cfloop list="#linkids#" index="i" delimiters=","> <cfoutput> <cfloop list="#i#" index="y" delimiters="-"> <cfif #IsNumeric(y)# EQ "YES"> <cfset idlist = #ListAppend(idlist, y, ",")#> <cfelse> <cfset name_list = #ListAppend(name_list, y, ",")#> </cfif> </cfloop> </cfoutput> </cfloop> <cfset idarray = #ListToArray(idlist, ",")#> <link href="naturalimage.css" rel="stylesheet" type="text/css"> <cfoutput> <cfif NOT IsDefined("num")> <cfset num = 1> </cfif> <cfloop list="#name_list#" index="name" delimiters=","> <tr> <td align="left" valign="top"> <a href="index.cfm?ID=#Trim(idarray[num])#">#name#</a> </td> </tr> <cfset num = IncrementValue(num)> </cfloop> </cfoutput> Many thanks for any help in advance. |
||||||||||||
|
|
|||||||||||||
|
Ennio
|
Why do you send the LIST to an ARRAY, you can just loop on the LIST.
Use this function ListGetAt(list, position [, delimiters]) You could replace this line.
to something like this...
I did not test the code... but that should work... |
||||||||||||||||
|
|
|||||||||||||||||
|
tri_3sports_dfw
|
I the suggestion and got exactly what I thought I would. The two initial loops break apart the results of the getcontent.link_to result set. The results looks like "Blah - 1,Foo - 2". The values are inserted into either the name_list or idlist. So, the idlist would look like "1,2" and name_list like "Blah, Foo". Implementing the suggestion above causes the page to draw links with names and numbers instead of names with cooresponding numbers for the ID in the link.
Then in the final loop where the values are placed in the link. The name_list is looped over to place the name to be displayed to the user as a hyperlink. The idlist uses the index position of the array to determin the ID to be put in the address to be linked to. This is a problem that has only surfaced since the cf8 upgrade. |
||||||||||||
|
|
|||||||||||||
|
Ennio
|
I will take a look later at home... I got really busy this week... sorry...
But I was at your website now, and I saw that it added some extra text on the link. Like on the home link you have this
And what does the result should be? Some like this
|
||||||||||||||||
|
|
|||||||||||||||||
|
Ennio
|
can you display the value of your list (idlist, name_list , linkids) so I can do a test here on my computer for you
|
||||||||||||
|
|
|||||||||||||
|
tri_3sports_dfw
|
No worries I really appreciate the help. Work has kept me away from this site most of the week as well.
the following is how the variables would look if printed to the screen in a working scenario: linkids = Home - 1,Board - 2,Committees - 3,Guidelines - 4,Contact Us - 5,Classifieds - 13,Photo Album - 14,News Letters - 15,FTW Announcements - 19 idlist = 1,2,3,4,5,13,14,15,19 name_list = Home, Board, Committees, Guidlines, Contact Us, Classifieds, Photo Album, News Letters, FTW Announcements you are correct the link would be http://www.harvestridgehoa.com/index.cfm?ID=1 or <a href="index.cfm?ID=1">Home</a> if you viewed the source for that link Thanks for your help it is appreciated |
||||||||||||
|
|
|||||||||||||
|
Ennio
|
tri_3sports_dfw:
I changed your code a little be. I'm only using 2 lists, one for the number and another one for the names. If you keep then on the same order this will work. here is the code.
Just remember to remove your array from your code, since you will not be using it any more. |
||||||||||||||
|
|
|||||||||||||||
| CF8 and arrays acting strange |
|
||
|


