Include CF code in coldfusion generated template

2012-10-14 Thread wayne Gregori

I'm using cfsavecontent to create a bunch of .cfm files.  I need to
include a few lines of coldfusion code but I cannot figure out how to
include them into my templates without coldfusion executing them rather
than including them in the template in raw text format?

Any ideas?

Thanks,
Wayne


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352901
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Include CF code in coldfusion generated template

2012-10-14 Thread Russ Michaels

you will need to NOT use cfsavecontent in that case.
Just put the content into a variable and use CFFILE to save it.

On Sun, Oct 14, 2012 at 10:58 PM, wayne Gregori w...@sfnet.com wrote:


 I'm using cfsavecontent to create a bunch of .cfm files.  I need to
 include a few lines of coldfusion code but I cannot figure out how to
 include them into my templates without coldfusion executing them rather
 than including them in the template in raw text format?

 Any ideas?

 Thanks,
 Wayne


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352902
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Spam:****, Re: Include CF code in coldfusion generated template

2012-10-14 Thread wayne Gregori

Russ,

here's what I'm doing now... can you suggest the easiest way to save
this content to a variable?


!--- save to html file and write to disc ---
cfsavecontent variable=htmlDoc
cfinclude template=includes/master_plugin_realestate.cfm
/cfsavecontent
cffile action=write
file=/home/www/www.gregorigroup.com/htdocs/market_data/#trim(findregions.command_prefix)#_#dateformat(now(),'mm-dd-yy')#.cfm
 output='#htmlDoc#' mode=777

Thanks


On Sun, 2012-10-14 at 23:45 +0100, Russ Michaels wrote:
 you will need to NOT use cfsavecontent in that case.
 Just put the content into a variable and use CFFILE to save it.
 
 On Sun, Oct 14, 2012 at 10:58 PM, wayne Gregori w...@sfnet.com wrote:
 
 
  I'm using cfsavecontent to create a bunch of .cfm files.  I need to
  include a few lines of coldfusion code but I cannot figure out how to
  include them into my templates without coldfusion executing them rather
  than including them in the template in raw text format?
 
  Any ideas?
 
  Thanks,
  Wayne
 
 
  
 
 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352903
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best practice question for Application.cfc

2012-10-14 Thread Azadi Saryev

If it is only applicationname that you need to be unique, then you
could just use a hash of template path as app name, or some variation
of the below:

this.name = hash(getCurrenttTmplatePath());

Azadi

On Sat, Oct 13, 2012 at 10:47 PM, Nick Gleason n.glea...@citysoft.com wrote:

 Hi Folks,
 We're moving from application.cfm to application.cfc and I had a question
 regarding best practices.
 We re-use our base code and in the past, we have used a settings page that
 is external from the base code and unique per client to set the
 applicationname variable (and other variables).  This is called at the
 beginning of application.cfm and provides cfapplication with the unique
 application name.
 That same structure seems to work with application.cfc but requires calling
 a file at the top of application.cfc, above setting the application
 variables in application.cfc, to provide the applicationname.
 Is that approach (calling a file at the top of application.cfc to provide a
 unique client setting) considered a best practice for this kind of thing.
 Or, is there a more appropriate way?
 The only other thing I could think of would be to hard code the unique
 client applicationname in Application.cfc, but that would then require that
 Application.cfc be a unique file per client and thus not part of our core
 base code in the sense that we wouldn't include it in upgrades (so that it
 wouldn't over-write a unique client file with default values).
 Any thoughts on that?  Let me know if I'm not being clear.
 Thank you in advance!
 Nick




 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352904
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best practice question for Application.cfc

2012-10-14 Thread Nick Gleason

Many thanks Mike and Dave. Sounds like we're in the ball park.  If anyone 
else has different ways of doing it, let me know.  
Best,
Nick


Return-Path: listmas...@houseoffusion.com
Received: from mail.houseoffusion.com [64.118.74.225] by 
mail67.safesecureweb.com with SMTP;
   Sat, 13 Oct 2012 14:12:49 -0400
To: cf-talk cf-talk@houseoffusion.com
Message-ID: 
CAOnEp2f+=czlr6qqqsjymn6lvnqy0srlow5ts+ks8nv5+a6...@mail.gmail.com
Subject: Re: Best practice question for Application.cfc
References: 
CACi=xszchjy1aa1pzuhnjw5qktbat800vd+sasfjpmvugv9...@mail.gmail.com
Date: Sun, 14 Oct 2012 05:12:19 +1100
Precedence: bulk
Reply-To: cf-talk@houseoffusion.com
From: Mike Kear afpwebwo...@gmail.com
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Rcpt-To: n.glea...@citysoft.com
X-SmarterMail-Spam: SpamAssassin 0.6 [raw: 0.6], SPF_None, DK_None
X-SmarterMail-TotalSpamWeight: 0 

Which ever way you do it,  somewhere or other you have to have a file
that's unique to this site, or have a settings record in a database or
some such. Does it REALLY make much difference if it's a site-specific
Application.cfc or a site-specific Settings.xml file or a site-specific
Settings table in a database?

The way I do it is to have a config folder in the core code, which is 
where
I put the site-specific things that are called by the generic core code.
There's usually a config.xml with site name, application name, passwords 
to
things.  Then when I create a new site, I copy all the core code over,
 then go into the config folder and modify all the values in the
config.xml.The config.xml file is called into a config.cfc  that sets
up all the application and other critical variables for the site at
application start.

But I dont think you necessarily need to do it the way I do.I would
suggest though, that you keep all the site-specific variables in one place
 (in my case a config folder) so it's quick and easy to set up a new site.
  And also when you modify your code, you know that you can safely copy 
all
your modified files into your other similar sites without breaking all the
site-specific settings.

This is not related to whether or not you use Application.cfm or
Application.cfc.   The same principles apply however you set up your code.
 But since you are changing your architecture, it's a good time to examine
whether you have opportunities to make your code better organised.

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion 9 Enterprise, PHP, ASP, ASP.NET hosting from AUD$15/month

On Sun, Oct 14, 2012 at 1:46 AM, Dave Watts  wrote:


  We're moving from application.cfm to application.cfc and I had a 
question
  regarding best practices.
  We re-use our base code and in the past, we have used a settings page
 that
  is external from the base code and unique per client to set the
  applicationname variable (and other variables).  This is called at the
  beginning of application.cfm and provides  with the unique
  application name.
  That same structure seems to work with application.cfc but requires
 calling
  a file at the top of application.cfc, above setting the application
  variables in application.cfc, to provide the applicationname.
  Is that approach (calling a file at the top of application.cfc to
 provide a
  unique client setting) considered a best practice for this kind of 
thing.
  Or, is there a more appropriate way?
  The only other thing I could think of would be to hard code the unique
  client applicationname in Application.cfc, but that would then require
 that
  Application.cfc be a unique file per client and thus not part of our 
core
  base code in the sense that we wouldn't include it in upgrades (so 
that
 it
  wouldn't over-write a unique client file with default values).

 I think the most common approach for this sort of thing with
 Application.cfc is to use inheritance. You can have a base
 Application.cfc, then use the EXTENDS attribute to create a new
 Application.cfc with customized settings, overridden event handlers,
 etc.

 Dave Watts, CTO, Fig Leaf Software
 http://www.figleaf.com/
 http://training.figleaf.com/

 Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
 GSA Schedule, and provides the highest caliber vendor-authorized
 instruction at our training centers, online, or onsite.

 



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352905
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Spam:****, Re: Include CF code in coldfusion generated template

2012-10-14 Thread Russ Michaels

cfsavecontent is actually a plain cfml custom tag, so you could just take a
copy of it and put inside your site and modify it not the render the
content.

On Sun, Oct 14, 2012 at 11:52 PM, wayne Gregori w...@sfnet.com wrote:


 Russ,

 here's what I'm doing now... can you suggest the easiest way to save
 this content to a variable?


 !--- save to html file and write to disc ---
 cfsavecontent variable=htmlDoc
 cfinclude template=includes/master_plugin_realestate.cfm
 /cfsavecontent
 cffile action=write
 file=/home/www/
 www.gregorigroup.com/htdocs/market_data/#trim(findregions.command_prefix)#_#dateformat(now(),'mm-dd-yy')#.cfm
 output='#htmlDoc#' mode=777

 Thanks


 On Sun, 2012-10-14 at 23:45 +0100, Russ Michaels wrote:
  you will need to NOT use cfsavecontent in that case.
  Just put the content into a variable and use CFFILE to save it.
 
  On Sun, Oct 14, 2012 at 10:58 PM, wayne Gregori w...@sfnet.com wrote:
 
  
   I'm using cfsavecontent to create a bunch of .cfm files.  I need to
   include a few lines of coldfusion code but I cannot figure out how to
   include them into my templates without coldfusion executing them rather
   than including them in the template in raw text format?
  
   Any ideas?
  
   Thanks,
   Wayne
  
  
  
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352906
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Spam:****, Re: Include CF code in coldfusion generated template

2012-10-14 Thread Gerald Guido

This is what I do when writing code generators. I create templates and
escape them so they do not execute like so

cfsavecontent variable=bla
^cfoutput
 ^input type=hidden name=#MyPK# value=##url.#MyPK###
^cfif action eq edit_#query_name#
 ^input type=hidden name=event
value=#query_name#_edited.##Section##.##nav##
^cfelse
 ^input type=hidden name=event
value=#query_name#_added.##Section##.##nav##
^/cfif
^/cfoutput
/cfsavecontent

And then strip out the carets like so

cffunction name=CleanCode displayname=CleanCode access=public
hint=I Clean the Code before writing it to disk output=false
returntype=string
 cfargument name=MyCodeString displayname=My Code String hint=The
Code to be cleaned type=string required=true /
 cfreturnvar  replace(arguments.MyCodeString,^,,all) 
/cffunction

If you want to learn more about code generation check out the code
generator apps on RiaForge
http://www.riaforge.org/index.cfm?event=page.search#generator

I learned a lot from Brian Rinaldi's Illudium PU-36 Code Generator
http://cfcgenerator.riaforge.org/

Look at the CFML templates that he uses if you are not familiar with XSL.

HTH
G!

On Sun, Oct 14, 2012 at 9:31 PM, Russ Michaels r...@michaels.me.uk wrote:


 cfsavecontent is actually a plain cfml custom tag, so you could just take a
 copy of it and put inside your site and modify it not the render the
 content.

 On Sun, Oct 14, 2012 at 11:52 PM, wayne Gregori w...@sfnet.com wrote:

 
  Russ,
 
  here's what I'm doing now... can you suggest the easiest way to save
  this content to a variable?
 
 
  !--- save to html file and write to disc ---
  cfsavecontent variable=htmlDoc
  cfinclude template=includes/master_plugin_realestate.cfm
  /cfsavecontent
  cffile action=write
  file=/home/www/
 
 www.gregorigroup.com/htdocs/market_data/#trim(findregions.command_prefix)#_#dateformat(now(),'mm-dd-yy')#.cfm
 
  output='#htmlDoc#' mode=777
 
  Thanks
 
 
  On Sun, 2012-10-14 at 23:45 +0100, Russ Michaels wrote:
   you will need to NOT use cfsavecontent in that case.
   Just put the content into a variable and use CFFILE to save it.
  
   On Sun, Oct 14, 2012 at 10:58 PM, wayne Gregori w...@sfnet.com wrote:
  
   
I'm using cfsavecontent to create a bunch of .cfm files.  I need to
include a few lines of coldfusion code but I cannot figure out how to
include them into my templates without coldfusion executing them
 rather
than including them in the template in raw text format?
   
Any ideas?
   
Thanks,
Wayne
   
   
   
  
  
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:352907
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm