Solved

cfincludes and start tags and end tags

Posted on 2004-09-22
7
266 Views
Last Modified: 2013-12-24
I have a page.

It has 2 cfincludes.

I want to include a start tag in 1 include and the end tag in the other include.

For instance,

the first include might be

<cfoutput>#Now()#

and the other include would be

</cfoutput>

I would expect this to work but it does not.

It errors saying it cannot find the end tag.  If I used </cfoutput> in the main page instead of the include it says it cannot find the start tag.

It appears when it is checking to make sure you have start and end tags that it only is looking in each include statement for both the start and end tags.  In addition, the main page also appears to be looking for both the start and end tag.

Is there anyway I can seperate the start and end tages in different includes and get the page not to error.

I tried putting the < in the main file and then the first include looked like this

cfoutput>#Now()#

and then I put another < in the main file and the 2nd include looked like this
/cfoutput>

This did not error however the page just displayed #Now()#.  I was suprised by this.  What happenned to the <cfoutput> and </cfoutput>?

I really want to do this.  

Thanks, Franz
0
Comment
Question by:FranzRinkleff
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 9

Expert Comment

by:shooksm
ID: 12127911
"I really want to do this."

No you don't.  It makes the maintenance for the poor schlub who has to clean up your code after you leave a nightmare.  He gets to play follow the include files until he finds where you put all the end tags.  Don't do this.  There is no reason you can give me that you have to have functionality like this.

But the reason why it doesn't work is CFINCLUDE does not work like SSI where the included files are assembled before passing to the scripting engine.  Each included file is treated as a seperate CFM and parsed before running the code.  The advantages of this way of treating each include as a physically seperate file allows you to do dynamic includes where you can change the template property of an include on the fly before the page is physically to be processed.
0
 
LVL 1

Author Comment

by:FranzRinkleff
ID: 12128345
I still really want to do this.  

It is actually for ease of maintenance that I want to do this.

We have a custom tag with a lot of attributes.  Currently, we ALWAYS use the same values for the attributes in the start tag.   I figured if we used a CFINCLUDE we could define the tag once with all of the attributes and not have to cut and paste the entire tag everytime we want to use it.  In addition, in the future if we decide that we need to change one of the attributes we can just change them once in the cfinclude instead of finding every page which has used this tag and changing the attributes on each page.  I could see us eventually having 3 or 4 combinations of the attributes however even then I think it would be better to have 3 or 4 cfincludes.

However based on your answer I don't think I will be able to do it.

Do you have any ideas that would help me since cfinclude will not work?
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 12128492
Its not possible, the end tag needs to be in the same page..
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 17

Expert Comment

by:Tacobell777
ID: 12128499
If there is something you always want to include, then put it in your application.cfm file..
0
 
LVL 9

Accepted Solution

by:
shooksm earned 250 total points
ID: 12129498
So can't the call to the custom tag be in its own include?

Personally, I would set default values for every attribute using CFPARAM in the custom tag.  Make the default values what you are most likely to use on a majority of the pages, then on the pages where one or more attributes need to be set a different value, you just pass them in.  If you want to change an attribute for every page, it is one edit to the custom tag with the exception of the pages that overide the default value by passing in an attribute.
0
 
LVL 1

Author Comment

by:FranzRinkleff
ID: 12130285
The custom tag is used to call another program which creates another file.

It is the code in between the custom tags which appears in the created file.

Since the code in between the custom tags is different on every page it cannot be part of an include statement.

I was hoping to avoid having to put the custom start tags with all of their attributes in every file since as I stated before the attributes will probably always be the same or just a few variations which means I would only need a few different includes

If we ever wanted to change the attributes I also did not want to have to modify every file which has the custom tags.

Your idea using CFPARAM is probably as good as I am going to get.  I would still have to cut and paste the start tag but at least I would be able to change the attributes easily if I ever needed to do it.  

Thanks, Franz
0
 
LVL 9

Expert Comment

by:Jerry_Pang
ID: 12130298
either insert the tags inside the include page or separate them.

1st
your include.cfm
----
<cfoutput>
you include page here
</cfoutput>

that way you only have to call the include statement

or
2nd
<cfoutput>
<include here>
<include2 here>
</cfoutput>

Doing what you wanted makes the debug a lot troublesome.

i do suggest redesigning your code.
but still the end tag must be on the same page.
does your includes only for cfoutput? or for all coldfusion tags?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now