Hi , imagine that you have one layout and every point of that is made with another templates. how can i handle this situation. For example in the left column ,displaying list of subcategories depending on category which is displayed at this time in the center of site (<%yield :layout %> line). it might be develop , making navigations randomly changing like amazon.com
> Hi , imagine that you have one layout and every point of that is made > with another templates. how can i handle this situation. For example > in the left column ,displaying list of subcategories depending on > category which is displayed at this time in the center of site (<%> yield :layout %> line). it might be develop , making navigations > randomly changing like amazon.comI typically do it like this: layouts/application.html.erb: .... <div id=''main-content''> <%= yield %> </div> ... <div id=''left-column''> <%= yield :left_column %> </div> Then in my other views I do whatever is simplest to generate content for the left column... perhaps... <% content_for :left_column do %> <%= render :partial => ''left_column'' %> <% end %> Where that would pick up a specific left_column partial for that controller. That sort of thing... -philip
<% content_for :left_column do %> <%= render :partial => ''left_column'' %> <% end %> where this codes should be? in the layout folder? if i understand , i must generate 2 files (one is template ,other one is _left_column.html.erb partial templats) , am i right? On Jun 19, 9:53 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> > Hi , imagine that you have one layout and every point of that is made > > with another templates. how can i handle this situation. For example > > in the left column ,displaying list of subcategories depending on > > category which is displayed at this time in the center of site (<%> > yield :layout %> line). it might be develop , making navigations > > randomly changing like amazon.com > > I typically do it like this: > > layouts/application.html.erb: > > .... > <div id=''main-content''> > <%= yield %> > </div> > ... > <div id=''left-column''> > <%= yield :left_column %> > </div> > > Then in my other views I do whatever is simplest to generate content > for the left column... perhaps... > > <% content_for :left_column do %> > <%= render :partial => ''left_column'' %> > <% end %> > > Where that would pick up a specific left_column partial for that > controller. That sort of thing... > > -philip
On Jun 19, 2009, at 1:08 PM, lecielbleu wrote:> > <% content_for :left_column do %> > <%= render :partial => ''left_column'' %> > <% end %> > > where this codes should be? in the layout folder?No... that would go in say /app/views/products/_left_column.html.erb THen when you''re in your products views you could use the above to load up that left column.> if i understand , i must generate 2 files (one is template ,other one > is _left_column.html.erb partial templats) , am i right? > > > On Jun 19, 9:53 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: >>> Hi , imagine that you have one layout and every point of that is >>> made >>> with another templates. how can i handle this situation. For example >>> in the left column ,displaying list of subcategories depending on >>> category which is displayed at this time in the center of site (<%>>> yield :layout %> line). it might be develop , making navigations >>> randomly changing like amazon.com >> >> I typically do it like this: >> >> layouts/application.html.erb: >> >> .... >> <div id=''main-content''> >> <%= yield %> >> </div> >> ... >> <div id=''left-column''> >> <%= yield :left_column %> >> </div> >> >> Then in my other views I do whatever is simplest to generate content >> for the left column... perhaps... >> >> <% content_for :left_column do %> >> <%= render :partial => ''left_column'' %> >> <% end %> >> >> Where that would pick up a specific left_column partial for that >> controller. That sort of thing... >> >> -philip > >
what will be if i display another controller , it will give me undefined method cause left column is depended on product controller ,i want a template working in many controllers On Jun 19, 11:10 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> On Jun 19, 2009, at 1:08 PM, lecielbleu wrote: > > > > > <% content_for :left_column do %> > > <%= render :partial => ''left_column'' %> > > <% end %> > > > where this codes should be? in the layout folder? > > No... that would go in say /app/views/products/_left_column.html.erb > > THen when you''re in your products views you could use the above to > load up that left column. > > > if i understand , i must generate 2 files (one is template ,other one > > is _left_column.html.erb partial templats) , am i right? > > > On Jun 19, 9:53 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: > >>> Hi , imagine that you have one layout and every point of that is > >>> made > >>> with another templates. how can i handle this situation. For example > >>> in the left column ,displaying list of subcategories depending on > >>> category which is displayed at this time in the center of site (<%> >>> yield :layout %> line). it might be develop , making navigations > >>> randomly changing like amazon.com > > >> I typically do it like this: > > >> layouts/application.html.erb: > > >> .... > >> <div id=''main-content''> > >> <%= yield %> > >> </div> > >> ... > >> <div id=''left-column''> > >> <%= yield :left_column %> > >> </div> > > >> Then in my other views I do whatever is simplest to generate content > >> for the left column... perhaps... > > >> <% content_for :left_column do %> > >> <%= render :partial => ''left_column'' %> > >> <% end %> > > >> Where that would pick up a specific left_column partial for that > >> controller. That sort of thing... > > >> -philip
is there any sample code for this navigation, i tried to put variable in application controller , but it didnt work , when i put @var ="abc" in application controller then i wrote <%@var %> , it displayed nothing. On Jun 20, 12:01 pm, lecielbleu <canal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> what will be if i display another controller , it will give me > undefined method cause left column is depended on product > controller ,i want a template working in many controllers > > On Jun 19, 11:10 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: > > > On Jun 19, 2009, at 1:08 PM, lecielbleu wrote: > > > > <% content_for :left_column do %> > > > <%= render :partial => ''left_column'' %> > > > <% end %> > > > > where this codes should be? in the layout folder? > > > No... that would go in say /app/views/products/_left_column.html.erb > > > THen when you''re in your products views you could use the above to > > load up that left column. > > > > if i understand , i must generate 2 files (one is template ,other one > > > is _left_column.html.erb partial templats) , am i right? > > > > On Jun 19, 9:53 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: > > >>> Hi , imagine that you have one layout and every point of that is > > >>> made > > >>> with another templates. how can i handle this situation. For example > > >>> in the left column ,displaying list of subcategories depending on > > >>> category which is displayed at this time in the center of site (<%> > >>> yield :layout %> line). it might be develop , making navigations > > >>> randomly changing like amazon.com > > > >> I typically do it like this: > > > >> layouts/application.html.erb: > > > >> .... > > >> <div id=''main-content''> > > >> <%= yield %> > > >> </div> > > >> ... > > >> <div id=''left-column''> > > >> <%= yield :left_column %> > > >> </div> > > > >> Then in my other views I do whatever is simplest to generate content > > >> for the left column... perhaps... > > > >> <% content_for :left_column do %> > > >> <%= render :partial => ''left_column'' %> > > >> <% end %> > > > >> Where that would pick up a specific left_column partial for that > > >> controller. That sort of thing... > > > >> -philip