Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set number variable with string value

Status
Not open for further replies.
Mar 10, 2005
63
US
Is it possible to set a number to the value of a string.

i.e

<cfset 01 = "includes/pages/bios/01.cfm">

I know this particular syntax throws an error, but is there a way to do this? Thanks.
 
I'm trying to manage my includes. I would like to have a link with a variable and have that variable represent an included template.

i.e.


01 = "includes/pages/bios/01.cfm"

<cfinclude template=#page#>

Hope that's not confusing. I'm trying to make my link management easier.
 
sorry my bad... please try

<cfif FindNoCase('page=01','#CGI.QUERY_STRING#',0)>
this is true
<cfelse>
that is false
</cfif>

or

<cfif FindNoCase('page=01','#CGI.QUERY_STRING#',0)>
<cfinclude template='includes/pages/bios/01.cfm'>
</cfif>


 
OK, that seems to work, but it just doesn't seem pratical for a site that has hundreds of pages. Maybe someone has a suggestion as to the best way to many links to that many pages.
 
then why not create a dB table as follows

pageID link
1 link1
2 link2
....
1234 link1234


then

<cfparam name="URL.pageID" type="numeric" default="">

<cfquery name="getLinks" datasource="...">
select * from myTable
where pageid = URL.pageid
</cfquery>


<cfif getLinks.recordcount GT 0>
<!--- get there --->
<cfinclude template='#getLinks.link#'>
</cfif>

hope it helps...

 
Hmm, ok. That's a possibility. How about an menu using XML and CF. Is that doable?
 
Yes.

You can dump MySl data for example to create XML with Coldfusion.

Quick Example - Should get you going in the right direction.
(Not Tested)

Code:
<!--- Query Database --->
<cfquery name="GetNavigation" datasource="#dsn#">
   SELECT * FROM navigation 
   ORDER BY weight ASC
</cfquery>


<!--- Create XML --->
<cfxml variable="NavigationXML">
<NAVIGATION>
  <LINKS>
     <cfoutput query="GetNavigation">
     <TextLinks AnchorText="#GetNavigation.AnchorText#" Href="#GetNavigation.Href#"></MainNav>
     </cfoutput>
  </LINKS>
</NAVIGATION>
</cfxml>


<!--- Dump XML Document Object --->
<cfdump var=#NavigationXML#>


<!--- Write XML --->
<cffile action="write" file="Navigation.xml" output=#toString(NavigationXML)#>

----------------------------------------
Always Learning...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top