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

why use cfinclude

Guest
Feb 16, 2009 Feb 16, 2009
why use cfincludes for headers and footers instead of using templates?
TOPICS
Getting started
1.4K
Translate
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 ,
Feb 16, 2009 Feb 16, 2009
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.
Translate
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
Feb 16, 2009 Feb 16, 2009
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!
Translate
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 ,
Feb 16, 2009 Feb 16, 2009
> 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
Translate
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 ,
Feb 16, 2009 Feb 16, 2009
> 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
Translate
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 ,
Feb 16, 2009 Feb 16, 2009
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/
Translate
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
Advocate ,
Feb 16, 2009 Feb 16, 2009
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.

**Sorry, all, my browser did not properly refresh, so I never saw the other responses, which were the same as this one :)**



Translate
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
Feb 16, 2009 Feb 16, 2009
>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!
Translate
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
Advocate ,
Feb 16, 2009 Feb 16, 2009
Eric,

Over the years, I have grown to dislike Dreamweaver templates, especially those without the use of cfincludes (that's not meant as snotty as it might read!).

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
Translate
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
Feb 16, 2009 Feb 16, 2009
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
Translate
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 ,
Feb 16, 2009 Feb 16, 2009
> 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.


> 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
Translate
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
Advocate ,
Feb 16, 2009 Feb 16, 2009
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 attributes of the cfinclude tags used above assume 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
Translate
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 ,
Feb 17, 2009 Feb 17, 2009
LATEST
> 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.
Translate
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