Discussion:
why use cfinclude
(too old to reply)
ericd33065
2009-02-16 13:55:13 UTC
Permalink
why use cfincludes for headers and footers instead of using templates?
Dan Bracuk
2009-02-16 14:54:25 UTC
Permalink
What do you think cfinclude includes? If you don't know, the answer is in the cfml reference manual. If you don't have one, the internet does.
ericd33065
2009-02-16 15:05:38 UTC
Permalink
Thanks Dan, I think. My question was intended to inspire different methods and
seek insight - not to have the question thrown back as if it where completely
stupid? I know what cfincludes include, I was meerly comparing them to normal
templates where removing all the HTML code is not done. Thanks for not
answering the question and reminding me just how useless some replys can be!
Adam Cameron
2009-02-16 15:10:50 UTC
Permalink
Post by ericd33065
templates where removing all the HTML code is not done. Thanks for not
answering the question and reminding me just how useless some replys can be!
I think there's an element of garbage in, garbage out in play here.

As per my other response, your question is somewhat vague, and in the
context of ColdFusion, makes no sense. Dan was in line with the question,
I think.
--
Adam
Adam Cameron
2009-02-16 15:08:32 UTC
Permalink
Post by ericd33065
why use cfincludes for headers and footers instead of using templates?
When you say "templates" do you mean that facility in DreamWeaver that
simulates the factoring code out into separate files? Because a "template"
is CF parlance is a CFM or CFC file, so your question doesn't make sense in
the context of ColdFusion.
--
Adam
Azadi
2009-02-16 15:16:44 UTC
Permalink
what 'templates' are you talking about here?

.cfm/.cfc page can be referred to (and often is) as a template, just as
a plain .html page can, as well a million other things...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
craigkaminsky
2009-02-16 15:25:07 UTC
Permalink
Eric,

When you wrote "instead of using templates," what sort of templates do you
have in mind (CFML, XHTML, Dreamweaver Templates, etc.)?

I think I understand what you're getting at but wanted to clarify what your
ultimate comparison is.
ericd33065
2009-02-16 16:06:33 UTC
Permalink
Post by Adam Cameron
I think there's an element of garbage in, garbage out in play here.
Thanks for adding to the trash Adam. However this is what I mean in your
words: that facility in DreamWeaver that simulates the factoring code out into
separate files!

Thanks for all the replies and I apologize if my vauge question encouraged
such helpful???? answers. Azadi and Craig, thanks for your thoughts...you too
Adam!
Adam Cameron
2009-02-16 16:42:23 UTC
Permalink
Post by ericd33065
However this is what I mean in your
words: that facility in DreamWeaver that simulates the factoring code out into
separate files!
Right: that makes sense now. Bear in mind that this is a CF forum, not a DW
forum, so when you say "template", people here are going to instinctively
think you mean the CF definition of that term; they're not going to guess
you're asking about DW. I don't think that's unreasonable.

DW templates are just a trick of DW. That's not just a truism: the
ramification of that is that the DW templating mechanism is meaningless
concept outside of DreamWeaver. That's not to be dismissive, but a lot of
people don't use DreamWeaver for doing their CF coding. So that's probably
the first reason not to use a tool-specific feature when writing code.

Secondly, DW templates are an HTML-document-centric conceit, wherein
there's - ultimately - a single file for the entire HTML response. That's
really not the way anyone other than a dabbler would write their CF code,
because it becomes unmanageable very quickly.

Now, if you are just a dabbler - I don't mean that derisively - and the
extent of your dynamicism in your HTML coding is to factor out repeating
regions within a layout, AND the code is only ever going to be maintained
with DW... yeah, why not: use DW templates.
Post by ericd33065
Thanks for all the replies and I apologize if my vauge question encouraged
such helpful???? answers. Azadi and Craig, thanks for your thoughts...you too
Adam!
NP.
--
Adam
Peggie Brown
2009-02-17 21:10:18 UTC
Permalink
Post by Adam Cameron
Now, if you are just a dabbler - I don't mean that derisively - and the
extent of your dynamicism in your HTML coding is to factor out repeating
regions within a layout, AND the code is only ever going to be maintained
with DW... yeah, why not: use DW templates.
DW Template function requires uploading ever single page
affected by a change. Includes (be the CF or simple SSI)
mean you only have to upload one text file to make a change
on every page affected.

craigkaminsky
2009-02-16 16:15:51 UTC
Permalink
Eric,

Over the years, I have grown to dislike Dreamweaver templates, especially
those without the use of cfincludes.

While DW templates are effective for static or brochure-type sites when used
in conjunction with Contribute, I find they are a great hinderance for a web
application (i.e., a dynamic site). For me, the problem is when you go to make
a change to a DW template in a large site, DW has to update every page across
the site that is based on that template and then your synchronization takes
much longer.

If I'm working on a site without the use of a CF framework (Fusebox,
Model-Glue, ColdBox, etc.), I try to use cfincludes for as much code as
possible, as this improves modularity and decreases the amount of files I need
to update. This way, even if your site uses DW templates (with cfincludes for
as much commonly used code as possible -- headers, navigation, sidebars,
footers, etc.), you have far fewer files that need to be updated and synced to
a server. Using common headers and footers (to name just two) in any CF-driven
site saves a lot of time, in my opinion.

You can get more efficient with code reuse if you migrate towards a CF
framework (ignore this if you've already checked some of these out :). There
are some awesome ones (and more) out there that I noted above. And, they can
really speed up your development and make site maintenance so much easier.

Best,
Craig
ericd33065
2009-02-16 16:31:04 UTC
Permalink
Craig...so using cfincludes for common code (as you said headers, footers, etc)
speed up development and reduce the need to update entire pages. I can see this
adds to making your pages more flexable? More areas of the page can be edited
while note affecting the common elements. Do have that right?

Thanks
craigkaminsky
2009-02-16 16:56:19 UTC
Permalink
You got it! A very simple (very, very simple :) use of includes would be the
following:
main.dwt file
<html>
<head>
<cfinclude template="header.cfm"/>
</head>
<body>
<cfinclude template="footer.cfm" />
</body>
</html>

The template attribute above assumes that the two CFML files, header.cfm and
footer.cfm are in the same directory as the including file.

Then, in the footer.cfm, for example, you might have the following:
<div id="footer">
<p>&copy; #Year(Now())# My Company</p>
</div>

Going forward, if you suddenly need to change your company name, you only have
to edit the footer.cfm file and not all the pages based on main.dwt.

To me, and (I think) many others, this is a much preferred method of breaking
up your files. I'd much rather edit my single footer.cfm and upload just that
one file to my server than 100 or something like that!

Hope that helps get you going with includes in CF!

Best,
Craig
Loading...