Solved

cfincludes and start tags and end tags

Posted on 2004-09-22
7
267 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

15 Experts available now in Live!

Get 1:1 Help Now