gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-12 02:07 UTC
question about dynamic layout
Hi, I have implemented a method where javascript would be found in an index file, and depending on the result, a session variable would be set to determine the layout the user is to use. Now heres the problem. Not only does javascript determine the layout, but the user can manually force 1 layout versus another. so think of this process: user goes to mysite.com/index (javascript determines which layout to use, for this case, lets say it uses layout2) user then manually goes to mysite.com/layout1 (layout1 is set in the session variable and used) up to this point, everything is working fine, but imagine if the user click back, and then clicks on a link, from the users perspective, it would seem like layout2 would be used, since thats the layout that was used when the link was clicked on, but since layout1 was the last set session variable, it will be used instead. i want to avoid this problem, so i have been trying to figure out a way to pass the layout mode as a params value (i.e. mysite.com/page? layout=1). Is this a good idea? is there was another way to do this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
gmoniey <big snip> > i want to avoid this problem, so i have been trying to figure out a > way to pass the layout mode as a params value (i.e. mysite.com/page? > layout=1). Is this a good idea? is there was another way to do this? I don''t understand your question but here is my answer : in the controller : ------------------- .. layout proc {|controller| if controller.action_name conditon = .... condition ? ''layout_1'' : ''layout_2'' else ''layout_3'' end } .. Alain Ravet -------- blog.ravet.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
gmoniey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-13 21:37 UTC
Re: question about dynamic layout
Hi Alain, i actually have something like that already, but here is the problem.... lets imagine you go to mysite.com/page1 and that page sets the condition so that layout1 is used (for all links on that page)...i.e. lets say these is an "About" link...when it is clicked, layout1 is used.....now, lets say the user navigates to mysite.com/page2 and that page sets the condition so that layout2 is used. here is where i feel my design is flawed....if the user is to click the back button (i.e. goes back to mysite.com/page1) and clicks on a link, layout2 is going to be used (since that is the last layout the condition has been set to)....this is a mistake (in my mind), since i think that layout1 should come up, since that is whats expected... i have been thinkin about how to address this, and it seems that other than using different explicit actions to define the layouts....or pass the current layout as a parameter (although this will end up with ugly URLs).... On May 12, 4:45 am, "Alain Ravet" <alain.ra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> gmoniey > > <big snip> > > i want to avoid this problem, so i have been trying to figure out a > > way to pass the layout mode as a params value (i.e. mysite.com/page? > > layout=1). Is this a good idea? is there was another way to do this? > > I don''t understand your question but here is my answer : > > in the controller : > ------------------- > .. > layout proc {|controller| > if controller.action_name > conditon = .... > condition ? ''layout_1'' : ''layout_2'' > else > ''layout_3'' > end > } > .. > > Alain Ravet > -------- > blog.ravet.com/--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---