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

how to translate tags to CFScript

Guest
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

I want to use "pure" CFScript in my coding. there are many problems.

tags: <cfinclude to cfscript include

tags:

<cfswitch expression="#REQUEST.Attributes.Go[ 1 ]#">

<cfcase value="error">
  <cfinclude template="./content/error/_index.cfm"/>
</cfcase>

<cfcase value="pickup">
  <cfinclude template="./content/pickup/_index.cfm"/>
</cfcase>

<cfcase value="send">
  <cfinclude template="./content/send/_index.cfm"/>
</cfcase>

<!--- Default to home. --->
<cfdefaultcase>
  <cfinclude template="./content/home/_index.cfm"/>
</cfdefaultcase>

</cfswitch>

it works well

cfscripts:

<cffunction name="include">
  <cfargument name="template">
  <cfinclude template="#template#">
</cffunction>

<cfscript>
switch("#REQUEST.Attributes.Go[ 1 ]#")
{
  case "error": include("./content/error/_index.cfm");
  case "pickup": include("./content/pickup/_index.cfm");
  case "send": include("./content/send/_index.cfm");
  default: include("./content/home/_index.cfm");
}

not work well.

ps: code(tags) above is from Ben Nadel's eCards project.

anyone can help me ? thanks!

Views

834

Translate

Translate

Report

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

LEGEND , Apr 19, 2012 Apr 19, 2012

You need to read the docs:

Using switch and case statements

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a0e0-7fdf.html#WSB69283B9-CA98-4fdf-95C2-80665F57BC82

Note that CASE blocks need to end with a BREAK.

Also, when asking a question, saying something "not work well" is not much help: you need to say in what way something doesn't work, eg: it causes an error, or you see something you didn't expect, etc.  Otherwise it's a bit ambiguous.

--

Adam

Votes

Translate

Translate
LEGEND ,
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

You need to read the docs:

Using switch and case statements

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a0e0-7fdf.html...

Note that CASE blocks need to end with a BREAK.

Also, when asking a question, saying something "not work well" is not much help: you need to say in what way something doesn't work, eg: it causes an error, or you see something you didn't expect, etc.  Otherwise it's a bit ambiguous.

--

Adam

Votes

Translate

Translate

Report

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
Guest
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

LATEST

thanks Adam! I get it just one minute ago. I'm a newbie

<cfscript>

switch("#REQUEST.Attributes.Go[ 1 ]#")

{

  case "error":

  {

    include "./content/error/_index.cfm";

    break;

  }

  case "pickup":

  {

    include "./content/pickup/_index.cfm" ;

    break;

  }

  case "send":

  {  

   include "./content/send/_index.cfm" ;

   break;

  }

  default:

  {

   include "./content/home/_index.cfm" ;

   break;

  }

}

</cfscript>

that work well!

Votes

Translate

Translate

Report

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
Documentation