Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cfincludes and start tags and end tags

Posted on 2004-09-22
7
Medium Priority
?
276 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
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month5 days, 18 hours left to enroll

772 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