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

CFIF statement problems

Explorer ,
Oct 22, 2008 Oct 22, 2008
I'm trying to set a default variable for a website I'm creating and this code isn't working.

Any help would greatly be appreciated.

651
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

correct answers 1 Correct answer

Explorer , Oct 22, 2008 Oct 22, 2008
Thanks Mikey.

This was the answer we were looking for.

We tried to do the cfparam but we did it backwords.

Can someone explain how this code functions?

Thanks

Derek
Translate
Engaged ,
Oct 22, 2008 Oct 22, 2008
Not sure why it wouldn't work, seems fine to me. You could try the CFPARAM approach. E.g.

<cfparam name="url.dealer" type="string" default="acura" />
<cfset variables.dealername = url.dealer />
<cfoutput>#url.dealer#</cfoutput>

That should work - but check it!

Thanks,
Mikey.
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 ,
Oct 22, 2008 Oct 22, 2008
Thanks Mikey.

This was the answer we were looking for.

We tried to do the cfparam but we did it backwords.

Can someone explain how this code functions?

Thanks

Derek
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 ,
Oct 22, 2008 Oct 22, 2008
What error are you getting?
It looks fine to me - although I tend to use single quotes isDefined ('URL.dealer')

Michael
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
Engaged ,
Oct 22, 2008 Oct 22, 2008
Basically, if url.dealer doesn't have a value, the CFPARAM kicks in and populates url.dealer with the default value you specify. It's a really nice and clean way of supplying a default value instead of doing loads of CFIF etc. However, it is kind of limited in some ways.

Cheers!
Mikey.
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 ,
Oct 22, 2008 Oct 22, 2008
I appreciate the breakdown Mikey. I'm saving this one in my memory banks.

You wouldn't believe how long we worked on trying to get this to work.
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 ,
Oct 22, 2008 Oct 22, 2008
LATEST
> I appreciate the breakdown Mikey. I'm saving this one in my memory banks.
>
> You wouldn't believe how long we worked on trying to get this to work.

Referring to the docs is always handy to explain stuff:

<cfparam>
http://livedocs.adobe.com/coldfusion/8/Tags_p-q_01.html

isDefined()
http://livedocs.adobe.com/coldfusion/8/functions_in-k_14.html

(or better) structKeyExists()
http://livedocs.adobe.com/coldfusion/8/functions_s_27.html

--
Adam
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