Sharing Layouts (and views)

12 views
Skip to first unread message

Jesus V.

unread,
Sep 30, 2008, 6:22:43 AM9/30/08
to ColdBox Framework
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,
Jesus

Ernst van der Linden

unread,
Sep 30, 2008, 6:39:45 AM9/30/08
to col...@googlegroups.com
You could use RenderExternalView()

See docs for example.

Ernst

Sana

unread,
Sep 30, 2008, 7:41:20 AM9/30/08
to ColdBox Framework
Hi Jesus,

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

setLayout(application2/layout/layout.Application2Report)

Thanks

Jesus V.

unread,
Sep 30, 2008, 10:12:50 AM9/30/08
to ColdBox Framework
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">
</Layout>

but I received the following error:

"Could not find the included template /phonebook/layouts/
CommonLayout.cfm"

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

Thanks,
Jesus

Luis Majano

unread,
Sep 30, 2008, 1:46:29 PM9/30/08
to col...@googlegroups.com
Jesus,

Unfortunately, the layouts are constricted to their covnentions within an application.  We only have as of now a Views External Location setting: http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbConfigGuide#ViewsExternalLocation

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.

Luis

Ernst van der Linden

unread,
Sep 30, 2008, 5:23:01 PM9/30/08
to col...@googlegroups.com
Why not create a simple layout like this? :


#renderExternalView('c:\........\mysharedviews\skins\1\header.cfm')#
#renderView()#
#renderExternalView('c:\........\mysharedviews\skins\1\footer.cfm')#

Ernst van der Linden

unread,
Sep 30, 2008, 5:25:59 PM9/30/08
to col...@googlegroups.com
or
:
#renderExternalView('c:\........\mysharedviews\skins\1\beforeRenderView.cfm')#
#renderView()#
#renderExternalView('c:\........\mysharedviews\skins\1\afterRenderView.cfm')#

Jesus V.

unread,
Oct 1, 2008, 4:10:19 AM10/1/08
to ColdBox Framework
Ernst,

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

<Layouts>
<!--Declare the default layout, MANDATORY-->
<DefaultLayout>../../common/ui/layouts/Layout.Common.cfm</
DefaultLayout>
...
</Layouts>

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
paths).

<cfoutput>#renderExternalView('/common/ui/views/UserInfo')#</
cfoutput>

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
(<DefaultLayout>../../common/ui/layouts/Layout.Common.cfm</
DefaultLayout>) but just an absolute one (<DefaultLayout>/common/ui/
layouts/Layout.Common.cfm</DefaultLayout>).

Jesus

On Sep 30, 11:25 pm, "Ernst van der Linden" <evdlin...@gmail.com>
wrote:
> or
> :
> #renderExternalView('c:\........\mysharedviews\skins\1\beforeRenderView.cfm')#
> #renderView()#
> #renderExternalView('c:\........\mysharedviews\skins\1\afterRenderView.cfm')#
>
> On Tue, Sep 30, 2008 at 11:23 PM, Ernst van der Linden
>
> <evdlin...@gmail.com> wrote:
> > Why not create a simple layout like this? :
>
> > #renderExternalView('c:\........\mysharedviews\skins\1\header.cfm')#
> > #renderView()#
> > #renderExternalView('c:\........\mysharedviews\skins\1\footer.cfm')#
>
> > On Tue, Sep 30, 2008 at 7:46 PM, Luis Majano <lmaj...@gmail.com> wrote:
> >> Jesus,
>
> >> Unfortunately, the layouts are constricted to their covnentions within an
> >> application.  We only have as of now a Views External Location setting:
> >>http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbConfigGuide#Vi...

Jesus V.

unread,
Oct 1, 2008, 4:13:30 AM10/1/08
to ColdBox Framework
By the way, any idea on why I get this error:

"Could not find the included template /application1/layouts/
CommonLayout.cfm"

When I try the <Layout> tag like this:

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

?

Thanks,
Jesus

Luis Majano

unread,
Oct 1, 2008, 1:04:53 PM10/1/08
to col...@googlegroups.com
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?

Luis
Reply all
Reply to author
Forward
0 new messages