[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

read and write a cf page?

I have a dynamic  .cfm page, that displays data from DB based on the ID of a product passed in the URL at the top of the page, very simple stuff i.e. product-page.cfm?prodID=1

Now I have another application which I want to get and read the product-page.cfm page, then  pass a URL i.e  product-page.cfm?prodID=2, save the outputted file, rename it. i.e. I now have a static file called some-product.cfm which is the same as if I have done product-page.cfm?prodID=2?

Does any of that make sense? Well if it does here is tricky part, I still want the new page recreated to be a cf one. i.e its dynamic still not a static output.

Before I did all this with cfhttp read then write the new file, only this method created a static page which cannot process cf after.

so now have this code (below) which works, but the new page I have to still pass a url to get it to do anything

If none of that make sense sorry


    <cffile
     action = "read"
      file = "#productPageTemplate#"
      variable = "productPageContent"
       >
   

      <cffile action="write"
                        output="#productPageContent#?prodId=#prodId#"
                        file="#productPageLocation##productPageName##productExt#"
                        nameconflict="overwrite">
0
pigmentarts
Asked:
pigmentarts
1 Solution
 
Scott BennettCommented:
Try reading the original file then adding a cfparam tag to the output of the new file like:

  <cffile
     action = "read"
      file = "#productPageTemplate#"
      variable = "productPageContent"
       >
   

      <cffile action="write"
                        output="<cfparam name=""url.prodID"" default=""2"">#productPageContent#"
                        file="#productPageLocation##productPageName##productExt#"
                        nameconflict="overwrite">
0
 
pigmentartsAuthor Commented:
SBennett, yes if what your saying is correct i mean i could fix the url.prodid at write, for ever and ever. cool. :) i try this out tomorrow and let you know. thank you!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now