0

I've tested several pages so far, and it seems that wherever I am attempting to use <CFHTMLHEAD> to add CSS or JavaScript to a CFM page in ColdFusion 11, it will not add it (works fine in CF8).

I read on SO about increasing the "Maximum Output Buffer size" in the Administrator > Server Setttings > Settings from the default valut of 1024KB, but every value I've tried (2048KB, 4096KB, and even the max allowed 999999KB) I get the same result - the content is not included in the <HEAD> tag when the page loads.

Has anyone else run into this and found a solution yet?

Code Sample:

htmlhead.cfm:

<cfif NOT ThisTag.HasEndTag>
    <cfthrow message="Missing end tag for custom tag htmlhead." type="HeadWrap" />
</cfif>

<cfif ThisTag.ExecutionMode is "End">
    <cfhtmlhead text="#ThisTag.GeneratedContent#" />
    <cfset ThisTag.GeneratedContent = "" />
</cfif>

index.cfm:

<cfsilent>
    <!--- 
        Data Retrieval, validation, etc. here
    --->

    <cf_htmlhead>
        <style type="text/css">
            tr.status-RETIRED td {
                color: #800000;
            }

            tr.status-PENDING td {
                color: #008000;
            }
        </style>
        <script type="text/javascript">
        $(function(){
            $(".options-menu").mouseleave(function(e){
                $(this).hide("fast");
            })

            $(".options-menu-link").mouseover(function(){
                $(".options-menu").hide("fast");

                $(".options-menu[data-sku='" + $(this).data("sku") + "']").show("fast");
            }).click(function(e){
                e.preventDefault();
            });
        });
        </script>
    </cf_htmlhead>
</cfsilent>

<!--- 
    Custom Tag layout.cfm contains the DOCTYPE declaration, html, head (loads jquery, jquery-ui, css, etc.), and body tags with a header and footer for each page.
--->
<cf_layout>
    <!--- Page Content Here (a form, a table, some divs, etc.) --->
</cf_layout>
Eric Belair
  • 10,574
  • 13
  • 75
  • 116
  • 3
    No error, just no results? Repro case? – Adam Cameron Jan 07 '15 at 17:31
  • @AdamCameron, no, there is no error. The page loads, but when I look in the HEAD in the source, the script and style tags I coded within CFHTMLHEAD tag are not there (causing parts of the page to display incorrectly and/or not function correctly). – Eric Belair Jan 07 '15 at 22:16
  • 1
    OK, and the second (and *main*) part of my question: repro case? IE: give us some code that demonstrates what you're seeing. http://sscce.org/ – Adam Cameron Jan 07 '15 at 23:43
  • @AdamCameron see the code sample I added. – Eric Belair Jan 08 '15 at 22:02
  • 1
    @EricBelair are you writing your own `` with ``? why? – Henry Jan 09 '15 at 00:56
  • @Henry because it's easier to see the actual code on the page rather than stuffing it all in a `` text attribute, or worse using ``. It's a simpler setup that I can easily reuse. But that's not the issue here. – Eric Belair Jan 09 '15 at 12:51

1 Answers1

3

I've found that in CF11 anything added using a cfhtmlhead call that comes before a cfcontent reset="true" does not get added to the resulting document. Does the cf_layout tag you are calling after your cf_htmlhead contain a content reset?

For example,

<!--- This will not be added under CF11. --->
<cfhtmlhead text="<!-- I'm some content that will only be included in CF10 or lower. -->">

<cfcontent reset="true">

<!--- This will be added under CF11 and lower. --->
<cfhtmlhead text="<!-- I'm some content that will be added in CF11 and lower. -->">

... the rest of your view code ...

<!--- This is a sample of the content you will get under CF11 --->
<!doctype html>
<html>
<head>
   <meta charset="UTF-8" />
   <title>Head Testing</title>
      <!-- I'm some content that will be added in CF11 and lower. -->
   </head>
   <body>
      <h1>Page content</h1>
   </body>
</html>
Dave Jones
  • 46
  • 2