Moonbase7

cf_space

 

June 27, 2009 - 1:22 PM (GMT)

Category: Coldfusion,tech notes
Author: Charles

I am currently redoing the help files for coreforms.  I have to totally redo them because I have added a bunch of new features, and I don't think the current version is that useful.  You kind of know that your documentation needs changing when the author of whatever you are trying to document has a hard time figuring them out.

So the solution I am working on needs a database so I can organize the documentation better.  The problem is that I do not want to require that people who want to view the documentation need to have a database connection and load a bunch of tables onto their server.  So I am trying some static ways to create coldfusion datasources.

The first way is to manually build out the query using coldfusion's queryNew, queryAddRow and querySetCell tags.

<cfset get_format = queryNew("name,description,status,attributes")>

<cfset queryAddRow(get_format)>
<cfset querySetCell(get_format,"name","text")>
<cfset querySetCell(get_format,"description","general text field, same features as an html text field")>
<cfset querySetCell(get_format,"status","A")>
<cfset querySetCell(get_format,"attributes","3")>

<cfset queryAddRow(get_format)>
<cfset querySetCell(get_format,"name","textarea")>
<cfset querySetCell(get_format,"description","general textarea field, same features as an html text field")>
<cfset querySetCell(get_format,"status","A")>
<cfset querySetCell(get_format,"attributes","4")>

This is ok for a small amount of rows, but I have another query that will hold all the attributes.  For this one I am going to use the basic concepts as the one above but build out a comma delimeted file first then loop through the data to create the query.

<cfsavecontent variable="theData">
1,fieldname,Yes,put the name of the query field,A,A
2,required,No,enter a Y if you need the field filled out,A,A
3,max,No,enter the total number of characters for a text field or a maximum date for a date field,A,S
4,cols,No,enter the number of columns for a textarea field just like the html attribute,A,S
</cfsavecontent>

<cfset theFields = "id,attributename,required,description,status,scope">

<cfset get_attributes = queryNew("#theFields#")>

<cfloop list="#theData#" delimiters="#chr(10)##chr(13)#" index="ii">
<cfset queryAddRow(get_attributes)>
    <cfset loopcounter = 1>
    <cfloop list="#thefields#" index="jj">
        <cfset querySetCell(get_attributes,"#jj#","#listgetat(ii,#loopcounter#)#")>
        <cfset loopcounter = loopcounter + 1>
    </cfloop>
</cfloop>

 Then all I have to do to get the query onto my page is to cfInclude the files that I put the above code on.


Share/Save/Bookmark

Comments:
No comments

Archives:
November 2008 (1)
December 2008 (2)
May 2009 (2)
June 2009 (1)
July 2009 (1)
September 2009 (3)
October 2009 (1)
December 2009 (1)
January 2010 (3)
July 2010 (1)
October 2012 (1)

Categories:
Coldfusion (7)
CompositeWeb (1)
coreforms (3)
Crazy Ideas (1)
fun (2)
ios (1)
iphone (1)
mac (3)
nature (1)
Notes (4)
OpenID (1)
Space (1)
tech notes (4)
video (1)
wiki (1)

Authors:
Charles (17)

Search:

rss feed All
rss feed Charles

This is the weblog of Charles Kaufmann.  All thoughts and opinions are solely his own (you wouldn't want them anyway).

Collaboration Suite

Are you looking for a way to get your group/company/non-profit to share files, calendars, forums, and more? CompositeWeb is offering a hosted Collaboration Suite solution so you have no IT costs, just an inexpensive monthly fee.  Try it for 30 days free!

Need some CMS?

If you are looking to create a site like this, check this out!  You can get a full featured site for free, all you have to do is sign up and add content.