hi, i''ve got main site navigation in the application.rhtml file. the links in this template correspond to the ''index'' page of various controllers. The controllers themselves each have navigation of their own, which i would like to appear in every view for a particular controller in *addition* to the main site navigation. The problem I am encountering is that when the app runs, the individual controller layouts take precedence over the layouts in application.rhtml which effectively removes the site navigation. what is the preferred rails way of allowing both a site-wide layout regardless of controller simultaneously with a per-controller layout? thanks!
Please bear in mind that I am a newbie and this may not be the preferred way
to do this:-
In the main application_helper I have this method:-
# Returns the name of the partial used for the application menu
def application_menu
@application_menu || ''shared/application_menu''
end
If I want to override this for individual controllers, all I need to do is
create the appropriate method in the correct helper, like so:-
def application_menu
@application_menu || ''shared/agecare_menu''
end
Now in my layout which is the main application.rhmtl I have
<%= render :partial =>"shared/html_head" %>
<body class= "<%= @controller.controller_name %>" >
<div id="wrapper">
<%= render :partial => application_menu %>
<div id="content">
<div id="content2">
<%= show_flash_messages :textilize => true %>
<%= @content_for_layout %>
<div id="clear">
</div>
</div>
</div>
<%= render :partial =>"shared/footer" %>
</div>
</body>
</html>
Here is example code for one of my partial menus, in this case
shared/agecare_menu:-
<div id="extranet_menu">
<%= render :partial => ''shared/top_menu'' %>
<h1><a href="/innovate">iNNOVATE</a></h1>
<ul id="main_menu">
<li class="first" id="home"><%= link_to
"Nursing and Residential
Homes", :controller =>
''home'', :action => "index"
%></li>
<li id="home_support"><%= link_to "Home Support
Agencies",
:controller =>
''home_support'', :action => "index"
%></li>
<li id="sheltered_development"><%= link_to
"Sheltered Developments",
:controller => ''sheltered_development'', :action
=> "index" %></li>
</ul>
</div>
The _top_menu partial is shared between the whole application. Hope this
helps
Regards
Harvey
On 4/2/06 20:07, "lester bangs" <dumpingrounds@gmail.com> wrote:
> hi,
>
> i''ve got main site navigation in the application.rhtml file.
> the links in this template correspond to the ''index''
> page of various controllers. The controllers themselves
> each have navigation of their own, which i would like to
> appear in every view for a particular controller in *addition*
> to the main site navigation.
>
> The problem I am encountering is that when the app runs,
> the individual controller layouts take precedence over
> the layouts in application.rhtml which effectively
> removes the site navigation.
>
> what is the preferred rails way of allowing both a
> site-wide layout regardless of controller simultaneously
> with a per-controller layout?
>
> thanks!
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
> This e-mail has been scanned for all viruses by MessageLabs.
This e-mail has been scanned for all viruses by MessageLabs.
Please bear in mind that I am a newbie and this may not be the preferred
way to do this:-
In the main application_helper I have this method:-
# Returns the name of the partial used for the application menu
def application_menu
@application_menu || ''shared/application_menu''
end
If I want to override this for individual controllers, all I need to do
is create the appropriate method in the correct helper, like so:-
def application_menu
@application_menu || ''shared/agecare_menu''
end
Now in my layout which is the main application.rhmtl I have
<%= render :partial =>"shared/html_head" %>
<body class= "<%= @controller.controller_name %>" >
<div id="wrapper">
<%= render :partial => application_menu %>
<div id="content">
<div id="content2">
<%= show_flash_messages :textilize => true %>
<%= @content_for_layout %>
<div id="clear">
</div>
</div>
</div>
<%= render :partial =>"shared/footer" %>
</div>
</body>
</html>
Here is example code for one of my partial menus, in this case
shared/agecare_menu:-
<div id="extranet_menu">
<%= render :partial => ''shared/top_menu'' %>
<h1><a href="/innovate">iNNOVATE</a></h1>
<ul id="main_menu">
<li class="first" id="home"><%= link_to
"Nursing and
Residential Homes", :controller =>
''home'', :action => "index"
%></li>
<li id="home_support"><%= link_to "Home Support
Agencies",
:controller =>
''home_support'', :action => "index"
%></li>
<li id="sheltered_development"><%= link_to
"Sheltered
Developments",
:controller => ''sheltered_development'', :action
=> "index"
%></li>
</ul>
</div>
The _top_menu partial is shared between the whole application. Hope
this helps
Regards
Harvey
On 4/2/06 20:07, "lester bangs" <dumpingrounds@gmail.com> wrote:
> hi,
>
> i''ve got main site navigation in the application.rhtml file.
> the links in this template correspond to the ''index''
> page of various controllers. The controllers themselves
> each have navigation of their own, which i would like to
> appear in every view for a particular controller in *addition*
> to the main site navigation.
>
> The problem I am encountering is that when the app runs,
> the individual controller layouts take precedence over
> the layouts in application.rhtml which effectively
> removes the site navigation.
>
> what is the preferred rails way of allowing both a
> site-wide layout regardless of controller simultaneously
> with a per-controller layout?
>
> thanks!
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
> This e-mail has been scanned for all viruses by MessageLabs.
lester bangs wrote:> hi,
>
> i''ve got main site navigation in the application.rhtml file.
> the links in this template correspond to the ''index''
> page of various controllers. The controllers themselves
> each have navigation of their own, which i would like to
> appear in every view for a particular controller in *addition*
> to the main site navigation.
>
> The problem I am encountering is that when the app runs,
> the individual controller layouts take precedence over
> the layouts in application.rhtml which effectively
> removes the site navigation.
>
> what is the preferred rails way of allowing both a
> site-wide layout regardless of controller simultaneously
> with a per-controller layout?
>
> thanks!
--
Posted via http://www.ruby-forum.com/.