Luis Majano Forums Notification: Post to Multiple Layouts same views

Title: RE: Multiple Layouts same views
Thread: Multiple Layouts same views
Forum: Need Help?
Conference: ColdBox
User: lmajano

Hi dodds,

I would have to know more about your design to give you my opinion.
However, from what I can assume, you need to create several different layouts
for the different type of users you have. You then have the same views for each,
just rendering in different layouts? is this correct?

Anyways, you can do this,
by setting the layout programmatically within each event. Here is an example of
changing the layout depending on type on my event handler. Look at the concept,
please don't copy and paste.

[code]
function dspUserData(){

//Do my logic here
....
//Declare the view to render
event.setView("vwUserdata");
//Dynamically change layout
if ( user.type eq "users" )
event.setLayout("layout.users");
else if (user.type eq
"techs")
  event.setLayout("layout.techs");

etc...
[/code]
Now, if this if statements can get large, and since you do not want them to be
copy pasting code everywhere, I would use the 'postHandler' method. This method
runs after each event and you can override layouts here, etc. If you have
multiple handlers needing this, then I would create a Layout Handler and execute
on the necessary events by using 'runEvent("ehLayout.setLayouts")' or
something along those lines.

Does this help you?

LM

http://www.luismajano.com/forums/index.cfm?event=ehMessages.dspMessages&threadid=7F24E411-123F-6116-42AA235412798CCB