You've got to use the 4 query-creation functions:
QueryNew, QueryAddColumn, QueryAddRow, QuerySetCell

Unfortunately, the only way to guarantee ordering is to use a
structured container, like an array or a query. You can use queries
for this, and then use QofQ to extract your data... or you could use
StructSort, to sort your struct elements either alphabetically or
numerically, should you choose to add a control element like
"sortOrder" that allows you to control the ordering explicitly.

Unfortunately, structSort returns an array of struct elements, so
you're still stuck using an array... however you can loop an array
easily enough...

Here's what a query system might look like:

<cffunction name="makeNav" access="public" output="false" returntype="query">
        <cfreturn queryNew("label","template")>
</cffunction>

<cffunction name="addItem" access="public" output="false">
        <cfargument name="LinkName" type="string" required="true" />
        <cfargument name="PageName" type="string" required="true" />
        
        <cfset queryAddRow(myNav)>
        <cfset querySetCell(myNav,"label",arguments["linkName"])>
        <cfset querySetCell(myNav,"template",arguments["PageName"])>
        
        <cfset setNavigation()>
        
        <cfreturn true>
</cffunction>

<cffunction name="setNavigation" access="private" returntype="VOID"
output="false">
        <cfargument name="NavItem" type="query" required="true" />

        <cfset StructInsert(variables.instance,"navigation",arguments.NavItem)>
</cffunction>

<cffunction name="getNavByNumber" access="public" returntype="struct"
output="false">
        <cfargument name="itemNumber" required="Yes" type="numeric" />
        
        <cfset var thisNav = structNew()>

        <cfset thisNav["linkName"] =
variables["instance"].navigation.navItem["label"][itemNumber]>
        <cfset thisNav["pageName"] =
variables["instance"].navigation.navItem["template"][itemNumber]>
        <cfreturn thisNav />
</cffunction>

Your array loop might look like this:

<cfloop from="1" to="#arrayLen(navArray)#" index="i">
<cfoutput>a href="#navArray[i]['linkName]#">#navArray[i]['pageName']#</a>
{whatever divider you were using}
</cfloop>

Hope that helps...

Laterz,
J

On Sun, 27 Feb 2005 23:16:11 -0800, Daniel Short <[EMAIL PROTECTED]> wrote:
> I'm not familiar with all of the query functions yet. Guess I better start
> fiddling with those. I'm assuming that I can just add rows at will to a
> query in a variable?
> 
> Thanks,
> 
> Dan
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Phil Cruz
> > Sent: Sunday, February 27, 2005 11:00 PM
> > To: [email protected]
> > Subject: Re: [CFCDev] Using Structures to handle navigation
> > (order problems)
> >
> > Use queryNew() to create query object.  You can add a column for
> > "position" so you can do a query of query to sort it (if it doesn't
> > maintain the inserted order).
> >
> > -Phil
> 
> 


-- 
Continuum Media Group LLC
Burnsville, MN 55337
http://www.web-relevant.com
http://cfobjective.neo.servequake.com

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]

Reply via email to