nick_harambee
asked on
i need some help to change this code which generates a table of thumbnails.
hello,
dldeeds kindly posted some coldfusion code which generates a table of thumbnails which each have a link to a html page. here is the code which i have adapted slightly for my purposes:
<cfdirectory directory="C:\CFusionMX\ww wroot\thum bnails\psy chotherapi sts"
action="list"
name="images"
filter="*.jpg"
sort="name ASC">
<!--- Set a counter to 0 and a var to hold the total number of images --->
<cfset numrec=images.RecordCount>
<cfset s=0>
<style type="text/css">
<!--
body {
background-color: #EDEAE4;
}
.style3 {font-size: x-small}
.style5 {font-size: 9px}
.style6 {font-size: larger}
.style8 {color: #666600}
.style9 {font-size: xx-large}
.style11 {font-size: xx-large; color: #666666; }
-->
</style>
<title>psychotherapists</t itle><tabl e width="100%" border="0">
<tr><td colspan="8" align="center" class="style9">
<p class="style8">Psychothera pists</p>< /td>
</tr>
<span class="style5">
<!--- Title row --->
</span><span class="style5">
<cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span><span class="style6">
<cfloop query=images>
</cfloop>
</span><span class="style5"><cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span><span class="style3"><cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span>
<cfloop query=images>
<!--- Create a variable to contain each Authors page (authorname.htm) --->
<cfset AuthorPage=ReplaceNoCase(i mages.name , ".jpg", ".htm")>
<!--- Create a variable to contain the Authors name to use under the image --->
<cfset AuthorName=ReplaceNoCase(i mages.name , ".jpg", "")>
<cfset s=s+1>
<!--- use modulus function to know when to change rows - this one is set up for 3 images per row --->
<cfset mods=(s mod 8)>
<cfoutput>
<cfif mods eq 1>
<tr>
</cfif>
<!--- Create a table cell for each image in the query --->
<!--- Each cell will contain the thumbnail which is also a link to the author page, with authors name under thumbnail --->
<td width="12%" td align="center" valign="top">
<A href="/psychotherapists/#A uthorPage# "><img src="/thumbnails/psychothe rapists/#i mages.name #" alt="thumbnail image" border="0"></A>
<br>
<span class="style8">#AuthorName #</span>
</td>
<cfif mods eq 0>
</tr>
</cfif>
<!--- If we are on the last image from the query, close the row if it has not been, then close the table --->
<cfif s eq numrec>
<cfif mods neq 0>
</tr>
</cfif>
</table>
</cfif>
</cfoutput>
</cfloop>
i would like to make 2 changes to this code:
(i) firstly, rather simply, i would like there to be a one line space between the title 'psychotherapists' and the table itself. i have tried putting a line break in various places, but can't get it to work.
(ii) at the moment the code sorts the thumbnails alphabetically according to the first name of the psychotherapists. i would like the text under the therapists to include the first name and to read, e.g. as 'sigmund freud' (which it does at present), but i would like to sort the thumbnails according to the surname, i.e. 'freud'. would it be possible to adapt the code to do this?
thanks
nick
dldeeds kindly posted some coldfusion code which generates a table of thumbnails which each have a link to a html page. here is the code which i have adapted slightly for my purposes:
<cfdirectory directory="C:\CFusionMX\ww
action="list"
name="images"
filter="*.jpg"
sort="name ASC">
<!--- Set a counter to 0 and a var to hold the total number of images --->
<cfset numrec=images.RecordCount>
<cfset s=0>
<style type="text/css">
<!--
body {
background-color: #EDEAE4;
}
.style3 {font-size: x-small}
.style5 {font-size: 9px}
.style6 {font-size: larger}
.style8 {color: #666600}
.style9 {font-size: xx-large}
.style11 {font-size: xx-large; color: #666666; }
-->
</style>
<title>psychotherapists</t
<tr><td colspan="8" align="center" class="style9">
<p class="style8">Psychothera
</tr>
<span class="style5">
<!--- Title row --->
</span><span class="style5">
<cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span><span class="style6">
<cfloop query=images>
</cfloop>
</span><span class="style5"><cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span><span class="style3"><cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span>
<cfloop query=images>
<!--- Create a variable to contain each Authors page (authorname.htm) --->
<cfset AuthorPage=ReplaceNoCase(i
<!--- Create a variable to contain the Authors name to use under the image --->
<cfset AuthorName=ReplaceNoCase(i
<cfset s=s+1>
<!--- use modulus function to know when to change rows - this one is set up for 3 images per row --->
<cfset mods=(s mod 8)>
<cfoutput>
<cfif mods eq 1>
<tr>
</cfif>
<!--- Create a table cell for each image in the query --->
<!--- Each cell will contain the thumbnail which is also a link to the author page, with authors name under thumbnail --->
<td width="12%" td align="center" valign="top">
<A href="/psychotherapists/#A
<br>
<span class="style8">#AuthorName
</td>
<cfif mods eq 0>
</tr>
</cfif>
<!--- If we are on the last image from the query, close the row if it has not been, then close the table --->
<cfif s eq numrec>
<cfif mods neq 0>
</tr>
</cfif>
</table>
</cfif>
</cfoutput>
</cfloop>
i would like to make 2 changes to this code:
(i) firstly, rather simply, i would like there to be a one line space between the title 'psychotherapists' and the table itself. i have tried putting a line break in various places, but can't get it to work.
(ii) at the moment the code sorts the thumbnails alphabetically according to the first name of the psychotherapists. i would like the text under the therapists to include the first name and to read, e.g. as 'sigmund freud' (which it does at present), but i would like to sort the thumbnails according to the surname, i.e. 'freud'. would it be possible to adapt the code to do this?
thanks
nick
ASKER
having changed the code as you suggested i get the following error message:
Invalid CFML construct found on line 10 at column 1.
ColdFusion was looking at the following text:
</
The CFML compiler was processing:
* a cfset tag beginning on line 9, column 6.
* a cfset tag beginning on line 9, column 6.
The Error Occurred in C:\CFusionMX\wwwroot\psych otherapist s1.cfm: line 10
8 : <cfloop query="imagesOrig">
9 : <cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam e, ".jpg", ""), " "), CurrentRow)
10 : </cfloop>
11 :
12 : <cfquery name="images" dbtype="query">
Invalid CFML construct found on line 10 at column 1.
ColdFusion was looking at the following text:
</
The CFML compiler was processing:
* a cfset tag beginning on line 9, column 6.
* a cfset tag beginning on line 9, column 6.
The Error Occurred in C:\CFusionMX\wwwroot\psych
8 : <cfloop query="imagesOrig">
9 : <cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam
10 : </cfloop>
11 :
12 : <cfquery name="images" dbtype="query">
Nick, sorry about that, I cannot test this code because I don't have the image names. I forgot a closing > ... this is a kind of error you should be able to fix yourself:
<cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam e, ".jpg", ""), " "), CurrentRow)>
<cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam
ASKER
thanks sigmacon
now i get this error message:
Parameter validation error for function QUERYADDCOLUMN.
The function takes 3 parameters.
The Error Occurred in C:\CFusionMX\wwwroot\psych otherapist s.cfm: line 7
5 : sort="name ASC">
6 :
7 : <cfset QueryAddColumn(imagesOrig, LastName)>
8 : <cfloop query="imagesOrig">
9 : <cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam e, ".jpg", ""), " "), CurrentRow)>
nick.
now i get this error message:
Parameter validation error for function QUERYADDCOLUMN.
The function takes 3 parameters.
The Error Occurred in C:\CFusionMX\wwwroot\psych
5 : sort="name ASC">
6 :
7 : <cfset QueryAddColumn(imagesOrig,
8 : <cfloop query="imagesOrig">
9 : <cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam
nick.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
now i get this error message:
Variable IMAGESORIG is undefined.
The Error Occurred in C:\CFusionMX\wwwroot\psych otherapist s.cfm: line 7
5 : sort="name ASC">
6 :
7 : <cfset QueryAddColumn(imagesOrig, 'LastName', arrayNew(1))>
8 : <cfloop query="imagesOrig">
9 : <cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam e, ".jpg", ""), " "), CurrentRow)>
Variable IMAGESORIG is undefined.
The Error Occurred in C:\CFusionMX\wwwroot\psych
5 : sort="name ASC">
6 :
7 : <cfset QueryAddColumn(imagesOrig,
8 : <cfloop query="imagesOrig">
9 : <cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam
Please refer to my earlier comment - I renamed the query in the directory listing so we didn't have to rename so much further down the road:
4) After your (updated) directory listing,
<cfdirectory directory="C:\CFusionMX\ww wroot\thum bnails\psy chotherapi sts"
action="list"
name="imagesOrig"
filter="*.jpg"
sort="name ASC">
4) After your (updated) directory listing,
<cfdirectory directory="C:\CFusionMX\ww
action="list"
name="imagesOrig"
filter="*.jpg"
sort="name ASC">
ASKER
thanks a lot sigmacon
this works fine now
nick.
this works fine now
nick.
2) <h1>psychotherapists</h1><
3) This entire piece of code doesn't seem to have any function and <span> is not allowed here anyway - you may want to delete all of it:
<span class="style5">
<!--- Title row --->
</span><span class="style5">
<cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span><span class="style6">
<cfloop query=images>
</cfloop>
</span><span class="style5"><cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span><span class="style3"><cfloop query=images>
</cfloop>
<cfloop query=images>
</cfloop>
</span>
4) After your (updated) directory listing,
<cfdirectory directory="C:\CFusionMX\ww
action="list"
name="imagesOrig"
filter="*.jpg"
sort="name ASC">
insert this code:
--------------------------
<cfset QueryAddColumn(imagesOrig,
<cfloop query="imagesOrig">
<cfset QuerySetCell(imagesOrig, "LastName", ListLast(ReplaceNoCase(nam
</cfloop>
<cfquery name="images" dbtype="query">
select *
from imagesOrig
order by LastName
</cfquery>
--------------------------