Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cfincludes and start tags and end tags

Posted on 2004-09-22
7
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
What You Need to Know when Searching for a Webhost Provider
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

660 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