Reputation: 49
I already create my web with the main index is in /localhost/store In the main body, there is a right sidebar with a profile information.
What I want to do is ... When I browsing to my detail post where the url is /localhost/posts/3, I want to change my right sidebar with another list of the new posting (like similar question on stackoverflow when I type my question). Is there any way I can detect my url (change from store to posts)?
Kindly your help please..
Upvotes: 0
Views: 73
Reputation: 3052
Not sure what you are asking exactly, but i think this is what you want to do In you views, you can detect the current page by using the following:
<% if current_page?(:controller => "", :action => "index") %>
....original right sidebar code.......
<% elsif current_page?(:controller => "posts", :action => "show") %>
....new right sidebar code.......
<% else %>
....do something else.......
<% end %>
I am using jquery to this with some ajax on my site(bit more complicated), but i think this might be sufficient for what you are asking. Hope it helps.
Upvotes: 1