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

Cffile Issues

Guest
Nov 16, 2006 Nov 16, 2006

Copy link to clipboard

Copied



I'm having a rather annoying problem - I'm trying to create a file through cffile - the contents need to be dynamic so there is a loop and a few conditions attached. I can't seem to get the CF running inside the cffile tag and for it to write the results as plain text inside that file.

This code needs to be processed and then written to the file in it's altered state.

Any advice greatly appreciated.

TOPICS
Advanced techniques

Views

275

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 , Nov 16, 2006 Nov 16, 2006
var MENU_ITEMS = [<br />
<cfloop query='read_navigation'>
<cfif sublevel EQ '0'>
['#read_navigation.title#', '#read_navigation.link#',
{'tw':'_self'},<cfif
#read_navigation.lastitem# EQ '1'>],<br /></cfif><br />
<cfelse>
   ['#read_navigation.title#', '#read_navigation.link#',
{'tw':'_self'}],<br /><cfif #read_navigation.lastitem# EQ '1'>],<br
/></cfif>
</cfif></cfloop>
];

You can't do an assignment like this. I'm not even sure where to start
on this. What you need to do is build a st...

Votes

Translate

Translate
LEGEND ,
Nov 16, 2006 Nov 16, 2006

Copy link to clipboard

Copied

var MENU_ITEMS = [<br />
<cfloop query='read_navigation'>
<cfif sublevel EQ '0'>
['#read_navigation.title#', '#read_navigation.link#',
{'tw':'_self'},<cfif
#read_navigation.lastitem# EQ '1'>],<br /></cfif><br />
<cfelse>
   ['#read_navigation.title#', '#read_navigation.link#',
{'tw':'_self'}],<br /><cfif #read_navigation.lastitem# EQ '1'>],<br
/></cfif>
</cfif></cfloop>
];

You can't do an assignment like this. I'm not even sure where to start
on this. What you need to do is build a string and then write that
string to a file with the cffile attribute. I would look into the
<cfsavecontent...> tag and|or string concactination.

Save Content Example
<cfsaveContent variable="Menu_Items">
TEXT and CFML that produces Text
#dateFormat(now(),"dd/mm/yyyy")#
</cfsaveContent>

String Concactination Example
Menu_Items = "Text "
Menu_Items = Menu_Items & "and CFML "
Menu_Items = Menu_Items & "that produces Text " &
dateFormat(now(),"dd/mm/yyyy")

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
Nov 17, 2006 Nov 17, 2006

Copy link to clipboard

Copied

LATEST


<cfsavecontent> and a bit of fiddling with the layout solved the problem.

Thanks Ian.

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