Heres a pattern that abstracts out common code to a single file and publishes out to the live site as an include file. Think snippet of html that gets included in the big file.
1. Create a layout file in any Template, layout.asp (clone out output would work great)
2. Create a filename.asp that checks for the layout and changes publishing path accordingly. This is so this particular layout has different name from output.asp
3. In the template we wish to include this code do this
To publish out the layout file you still need to set it up under the assets publishing properties. View -> Properties -> Publishing. Select the package in the first column then set the layout file to use. In this case it would be layout.asp.
1. Create a layout file in any Template, layout.asp (clone out output would work great)
2. Create a filename.asp that checks for the layout and changes publishing path accordingly. This is so this particular layout has different name from output.asp
if content.("_cmsLayout") = "layout.asp" then
content.add "_cmsPublishPath", replace(content.item("_cmsPublishPath"), "old_val", "new_val"
end if
3. In the template we wish to include this code do this
if content.isPublishing then
asset.setParam "_cmsLayout", "layout.asp"
<!--#include virtual="<% asset.getLink("path to asset that uses template with layout.asp file") %>" -->
'when the asset that asset.getLink() is referring to is published, one is published using layout.asp as the template and one using the standard output.asp
else
'include the code as if it was part of this template
system.include "/Template Path/layout.asp"
end if
To publish out the layout file you still need to set it up under the assets publishing properties. View -> Properties -> Publishing. Select the package in the first column then set the layout file to use. In this case it would be layout.asp.
Comments