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

CFSCRIPT and savecontent (or is it cfsavecontent?)

LEGEND ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

Hello, all,

I'm a bit confused about something, and I hope someone can set me straight.

According to a blog entry (from four years ago) by Adam Cameron, Adobe initially created a CFSCRIPT version of CFSAVECONTENT, and it was called "savecontent", which falls into step with the typical CFSCRIPT implementation of CF tags (ie, remove "CF" from the tag for the CFSCRIPT version.)

But according to Adam's blog entry, CF11 changed it to "cfsavecontent".

Now, we develop in CF10, but our production servers run CF11.  So, am I to understand that "savecontent" does not work in CF11???  Do I have to write conditionals and double my code in order to get it to work in both development (CF10) and production (CF11)?  Or is it backwards compatible, and "savecontent" will work in both versions?

V/r,

^ _ ^

Views

2.9K

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

Community Expert , Dec 27, 2018 Dec 27, 2018

This is probably going to be an unsatisfying answer. I tested this out on CF 2016, which is what I have locally installed on this particular machine. I did get an error using savecontent in CFSCRIPT, but when I changed it to cfsavecontent the error went away. That said, I couldn't get the contents of cfsavecontent to work the way I expected, reading Adam's blog post. I will confess that I really don't use CFSCRIPT for any heavy lifting in CFML, especially anything relating to the output of varia

...

Votes

Translate

Translate
Community Expert ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

This is probably going to be an unsatisfying answer. I tested this out on CF 2016, which is what I have locally installed on this particular machine. I did get an error using savecontent in CFSCRIPT, but when I changed it to cfsavecontent the error went away. That said, I couldn't get the contents of cfsavecontent to work the way I expected, reading Adam's blog post. I will confess that I really don't use CFSCRIPT for any heavy lifting in CFML, especially anything relating to the output of variables, so ...

Anyway, my guess is you'll probably have to rewrite your CFSCRIPT code accordingly.

Dave Watts, Fig Leaf Software

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
LEGEND ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

I tested it, too.  Within a try/catch.  And the scary thing is that the catch didn't trigger.  It just sent full-blown details of what failed.  NOT GOOD!    Something about "function keyword missing in FUNCTION declaration."  There is no function.

So.. more hackish things to do to get this working in both environments.  Thanks, Adobe.

V/r,

^ _ ^

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
LEGEND ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

Things just became more confusing.

I have a different system in our DEV environment that is running CF11.  For whatever reason, 'CFsavecontent' isn't working in CF11.  It's giving the same error that CF10 gave:  function keyword missing from FUNCTION declaration.

Now I don't know what to do.  Could Adam have been incorrect in reporting that CF11 changed to add the "cf" to savecontent??  Doubtful.. he's pretty serious when it comes to investigating things ACF.

But this leaves me stumped.

V/r,

^ _ ^

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
Community Expert ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

Well, my very simple test code doesn't give me that value, and it indicates that cfsavecontent doesn't throw an error while savecontent does. But the error I'm getting with savecontent isn't the one you're getting. Here's the code that's giving me the error:

<cfscript>

savecontent(variable="test") {

"test";

};

</cfscript>

<h1>Hi!</h1>

<cfoutput>#test#</cfoutput>

Adding "cf" to the beginning of savecontent gets rid of the error, but it doesn't actually create a variable with the word "test" in it. So I don't really know what's going on here, but I'm inclined to believe that Adam's article is correct despite what the documentation (which explicitly mentions CF 11) says here:

ColdFusion Help | What is supported in CFScript

Dave Watts, Fig Leaf Software

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
LEGEND ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

In our DEV environment, both CF10 and CF11 are giving the "function keyword missing from FUNCTION declaration" message with the following code:

cfsavecontent variable="myVar" { WriteOutput("TEST");}

But the following will work in both:

  savecontent variable="myVar" { WriteOutput("TEST");}

I can't see Adobe intentionally releasing the first version of CF11 (no updates) as one way, then changing it in a later update.  But I can't deny what's happening, here.

V/r,

^ _ ^

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
Community Expert ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

LATEST

OK, I didn't realize you needed writeOutput in the cfsavecontent. Once I put that in, I got the code to work correctly, but savecontent still generates the same error as before: "Invalid CFML construct found on line 2 at column 12." (Line 2 is where the savecontent line is.)

So, I would say that Adam is correct, and that you probably have something else going on in your code.

Dave Watts, Fig Leaf Software

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