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!
You need to read the docs:
Using switch and case statements
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
Copy link to clipboard
Copied
You need to read the docs:
Using switch and case statements
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
Copy link to clipboard
Copied
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!