Sharing controller between subsystems, multiple themes

25 views
Skip to first unread message

Raj Giri

unread,
Sep 12, 2018, 6:40:11 PM9/12/18
to framework-one
Hello, at long last I have updated my site from Fusebox to FW/1. It's been working great.

I also am updating the design of my site and have several different themes I'm working with. Right now I have a subsystem for each theme, so the files are all named the same, just the code in the /layouts and /views folder is different. In the controllers folder each subsystem, each controller contains an include to the main controller.

I'm guessing there's a more efficient way to do this, or is the way I'm doing it the best way?

Cameron Childress

unread,
Sep 13, 2018, 10:46:57 AM9/13/18
to framew...@googlegroups.com
On Wed, Sep 12, 2018 at 6:40 PM Raj Giri wrote:
I also am updating the design of my site and have several different themes I'm working with. Right now I have a subsystem for each theme, so the files are all named the same, just the code in the /layouts and /views folder is different. In the controllers folder each subsystem, each controller contains an include to the main controller.

If I were doing this, I'd only create layouts for each theme and keep all the HTML in the views the same. Meaning, not a subsystem for each theme. 

An overly simplified example given the action "foo:bar.hello":

/subsystems/foo/controllers/bar.cfc - controller
/subsystems/foo/views/bar/hello.cfm - view
/subsystems/foo/layouts/themeA.cfm - theme A
/subsystems/foo/layouts/themeB.cfm - theme B

Then in the bar.cfc:before() you can do something like this:

public any function before(required rc) {
var theme = someLogicToGetTheCorrectTheme();
variables.fw.setLayout("bar:#theme#"); // set specific theme here
super.before(rc);
}

Or you could do this:

/subsystems/foo/controllers/bar.cfc - controller
/subsystems/foo/views/bar/hello.cfm - view
/subsystems/foo/layouts/theme.cfm - theme 

...and in the theme layout file you do this:

[....]
<link href="/assets/css/#someLogicToGetTheCorrectTheme()#.css" rel="stylesheet" type="text/css">
[....]

More about before() and setLayout() is found here:


-Cameron
 


Sean Corfield

unread,
Sep 14, 2018, 12:00:00 AM9/14/18
to framew...@googlegroups.com

I’ll second what Cameron said and point you to https://github.com/framework-one/fw1/tree/develop/examples/skinning which overrides customizeViewOrLayoutPath() to provide themes. That’s very similar to what we do in ColdBox at work to provide a range of site themes across over a hundred sites on a single multi-tenant code base.

 

I would *not* use subsystems for this.

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 


From: framew...@googlegroups.com <framew...@googlegroups.com> on behalf of Cameron Childress <came...@gmail.com>
Sent: Thursday, September 13, 2018 7:46:44 AM
To: framew...@googlegroups.com
Subject: Re: [framework-one] Sharing controller between subsystems, multiple themes
 
--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-on...@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.

Raj

unread,
Sep 14, 2018, 5:35:14 PM9/14/18
to framew...@googlegroups.com
That's perfect, thanks! 
Reply all
Reply to author
Forward
0 new messages