0

I have an index page that calls several includes using variables. Part of my site has an inventory section. I would like to insert the name of the inventory item into the title tag. From the index, I can tailor the title tag in the header to show the section and categories, but since the query for the individual item is in the included file, that variable doesn't exist yet when the index comes up. I tried to use the cfhtmlhead from the inventory page, but it neither adds to nor replaces the title that is called in the index.cfm page. Here is my code, but it doesn't work.

<cfhtmlhead text="<title>xxxx</title>"></cfhtmlhead>

I guess, I could pass the inventory item name in the URL, but most items have spaces in them and then I have to deal with that too.

Thanks, Kirk

cfhtmlhead doesn't seem to work when it is in cfincludes

  • Can you include the files earlier? – Dan Bracuk Dec 27 '22 at 19:19
  • 1
    Sounds to me like you could do with a bit of a redesign of your code. I recommend reading up on MVC, and if it's not too late, use an MVC framework instead of just throwing files together (which is what's caused this problem). With the code as it stands, it seems like you are starting to generate the response HTML before you have done all the business logic for the response. Do the business logic first, THEN do the markup, and send it back to the client. Using a framework will save you a lot of effort in hand-cranking this stuff though. – Adam Cameron Dec 28 '22 at 14:30
  • 1
    This might help: https://stackoverflow.com/questions/413439/how-to-dynamically-change-a-web-pages-title – James A Mohler Dec 30 '22 at 18:21

0 Answers0