Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfif url.

Explorer ,
Aug 09, 2011 Aug 09, 2011

i have a dynamic spry link that displays only cities of a record. depending on the city one chooses, the resulting hyperlink page will display the product contents from that city. when i do this, the action page throw an error and my "communities" query does not showup in the binding tab. i would like to use just one action page to display the information from the city that was chosen, and not have to make multiple pages for each city.

Question: How can a text hyperlink be integrated in a CFIF statement? It works well with a variable and html, but i'm kinda stuck.

Here is the syntax that i'm using. First i will display the first page to where the link will be chosen from, then the action page's syntax:

FIRST PAGE

<cfquery name="Places_City" datasource="properties">
SELECT community.comid, community.comcity
FROM community
GROUP BY community.comcity
ORDER BY community.comcity desc
</cfquery>

<li><a href="#">Our Places</a>
    <ul><cfoutput query="places_city"><li><a href="community_places.cfm" id="places">#Places_City.comcity#</a></li></cfoutput>
     
    </ul>

ACTION PAGE

<cfif isdefined('url.PLACES') is "St. George">
<cfquery name="community" datasource="properties">    
SELECT community.*, unit.*
FROM community, unit
WHERE 0=0
AND unit.unicomid = community.comid
AND community.comcity= 'St. George'
</cfquery>

<cfelseif isdefined('url.PLACES') is "Salt lake city">
<cfquery name="community" datasource="properties">
SELECT community.*, unit.*
FROM community, unit
WHERE 0=0
AND unit.unicomid = community.comid
AND community.comcity= 'Salt lake city'
</cfquery></cfif>

825
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 09, 2011 Aug 09, 2011

IsDefined() returns either true or false.  It does not return the value of the variable you are checking.

From a logic perspective, checking for the existance of a url variable is a good idea.  However, once you know it's there, you can use it's value in your query, meaning that you only have to type it out once.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 09, 2011 Aug 09, 2011

I guessing that my action page should read:

ACTION PAGE

<cfif  #url.PLACES# is "St. George">
<cfquery name="community" datasource="properties">    
SELECT community.*, unit.*
FROM community, unit
WHERE 0=0
AND unit.unicomid = community.comid
AND community.comcity= 'St. George'
</cfquery>

<cfelseif #url.PLACES#  is "Salt lake city">
<cfquery name="community" datasource="properties">
SELECT community.*, unit.*
FROM community, unit
WHERE 0=0
AND unit.unicomid = community.comid
AND community.comcity= 'Salt lake city'
</cfquery></cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 09, 2011 Aug 09, 2011
LATEST

Too much code and too much conditional logic.  All you need it this:

AND community.comcity= '#url.places#'

You have some other issues as well.  cfqueryparam will solve some of them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources