Sharing Layouts (and views)

Hi all,

Is it possible to share layout files among applications? I mean,
having a layout file in a shared folder an make all the applications
read it while maintaining the possibility of having application-
specific layouts.

Something like this:

-- common
   >-- layouts
   > >-- Layout.Common.cfm
-- application1
   >-- layouts
   > >-- Layout.Application1Report.cfm
-- application2
   >-- layouts
   > >-- Layout.Application2Report.cfm

An access to the Layout.Common.cfm from both application1 and 2.

How should I set up the configuration file?

The same thing for views?

Thank you,

You could use RenderExternalView()

See docs for example.


Hi Jesus,

For sharing/accessing the Layout you do them like this in your event-



The problem with using setLayout is that if I later have to change the
path to the shared folder I have to change all references in the
handlers. Ok, I can set a variable at config level, but still...

For the default Layout I can use a relative path (it works), but not
absolute (which would be better) because it concatenates the value to
the application path.

Then I've tried the <Layout> tag

        <Layout file="Layout.Common.cfm" name="CommonLayout">

but I received the following error:

"Could not find the included template /phonebook/layouts/

Why is it using the name in the path instead of the file attribute?
What am I doing wrong?



Unfortunately, the layouts are constricted to their covnentions within an application. We only have as of now a Views External Location setting:

Maybe a LayoutsExternalLocation setting can be implemented, where you could have a common shareable external layout location.

Sounds like a good idea, any more opinions, suggestions?

The only caveat with the external layouts location is that it will follow the same pattern as the view external location. The framework will try the conventions location first, if it cannot find it, it will then go to the external location.


Why not create a simple layout like this? :




I already did something similar to your approach. Just that first I
declared the default layout like this:

    <!--Declare the default layout, MANDATORY-->


I don't like the ../.. thing but at least it works and if needed it's
to be changed only in one place and, what it's more important, only in
the configuration file.

Then I wrote this common layout using renderExternalView to point to
the composing views (just that I use url paths and not filesystem


Well, this approach is not bad for what I intend to do but, of course,
it would be nicer to have such a way to declare views/layouts
repositories to be search in cascade.

Still what I'd like better is not having to use a relative path

) but just an absolute one (<DefaultLayout>/common/ui/



By the way, any idea on why I get this error:

"Could not find the included template /application1/layouts/

When I try the <Layout> tag like this:

        <Layout file="Layout.Common.cfm" name="CommonLayout">



One thing to note Jesus is that layouts and views are meant to be brought in via conventions. So having absolute paths makes no difference, because they always get pre-pended with the “AppMapping” setting.

I think the best approach is to have an externalLayouts Covention that can be used to bring in external layouts.
Any other ideas?