coldfusionluceefw1

FW/1 How to set up multiple layouts


I want to have two different layouts for my site. default.cfm site wide layout, and in the admin section admin.cfm for the layout. Creating admin.cfm in /layouts and navigating to admin.index does show the admin template, but the default.cfm sitewide template is also displaying. How do you set these up so only one is showing that needs to be showing?

Looking at the FW/1 docs link it mentions setlayout() but when I tried to use that i get the error "Problem with metadata for admin (controllers.admin) because: Unable to getComponentMetadata(controllers.admin) because: No matching function [SETLAYOUT] found, near line 2 in C:\Sites\actmeio_fw2\controllers\admin.cfc"

component accessors="true" persistent="true" {
setLayout('admin');

public any function index(event, rc, prc) {
}

}


Solution

  • At the top of your admin.cfm layout template, try adding

    <cfscript>
    disableLayout();
    </cfscript>
    

    This should prevent the default.cfm outer layout being applied. For more details see https://framework-one.github.io/documentation/4.3/developing-applications/#views-and-layouts-in-more-depth