Replace special codes on Page Render
Hey all - I'm new the the forums here, so HELLO! I look forward to being part of the community and helping out as much as I can, but as with all new members, I come with a problem that needs solving...
I'm working with complex dynamic template files and, in an effort to simplify the template-building process and boost the efficiency of our system, I am looking for a way to replace something like a special character code to include a pre-defined construct.
For example - I have a template file that looks like this (simplified):
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/myStyles.css">
</head>
<body>
<div id="welcome">
Welcome to my Page!
</div>
<div id="navigation">
<cfinclude template="../rootFiles/builder_navigation.cfm">
</div>
</body>
</html>
The actual templates are much more complicated than this, but this should be enough for the purposes of demonstration. I am looking for a way to call (for example) my '../rootFiles/builder_navigation.cfm" -- I have two main fuctions the template serves, to represent itself for a builder as well as serve as a template for a publishing script. So, with this in mind, if I am using the builder, I need to call 'builder_navigation.cfm' but if I am publishing the template i need to call 'publish_navigation.cfm.'
So, the above script would be used for the builder, and the below script would be used when a publish is called...
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/myStyles.css">
</head>
<body>
<div id="welcome">
Welcome to my Page!
</div>
<div id="navigation">
<cfinclude template="../rootFiles/publish_navigation.cfm">
</div>
</body>
</html>
What I am hoping is that I can use a template file like the one below to dynamically call (through a CFINCLUDE) either the publish navigation script or the builder navigation script by using one 'keyword' or 'special code'
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/myStyles.css">
</head>
<body>
<div id="welcome">
Welcome to my Page!
</div>
<div id="navigation">
[TEMPLATE_NAVIGATION]
</div>
</body>
</html>
This way I can use the same file and call the appropriate navigation template depending on the need. I would use a simple <cfif> statement to determine which I need, but I need to keep this as plain HTML as I can as when the publish scripts are called I need plain HTML as the variables that would be needed by the <cfif> script would not exist after the published template has been created.
Thanks in advance!