Hello. It''s been a long night of trying to get thisapplication developed so forgive me if this post is a bit messed up. Is there a way to ''include'' html files in an rhtml file? I have a standard.rhtml file in my layouts folder, and want to include another rhtml file that contains the code for a navbar created with Macromedia Fireworks. The file also has all the javascript, etc that goes along with it, as well as references to the individual images and rollover states that go with it. With a PHP page I''d just put <?php include(''navbar.htm''); ?> but am not sure how to do it in ruby. also, I know by default that a when going to an url that corresponds to a model/controller, the ruby engine will parse the code. But is there a way to include PHP code in there as well? E.g, if I want to use ruby to get information from a database, but then want to use PHP and plain html to create a form and send its contents using e-mail? You can probably tell frm this that I''m new to ruby, and certainly at the present time most of my site will be using PHP/HTML. for the moment though, if anyone can advise me as to how I can get my navbar included into the rhtml file, I''d be grateful. Cheers. Hussein. -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
You want to use partials. Just make a new rhtml file and when you name it, make sure that you place an underscore before the first letter in the name. Then you can render it anywhere you want using render_partial => "your_partial_name_with_no_extension" But why are you trying to include a navbar into the rhtml file? Aren''t you using your layouts folder? The layouts in your project should take care of everything for you. -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
Sean Colquhoun wrote:> You want to use partials. Just make a new rhtml file and when you name > it, make sure that you place an underscore before the first letter in > the name. Then you can render it anywhere you want using render_partial > => "your_partial_name_with_no_extension"more like: #Stick your nav bar in app/views/some_controller/_foo.rhtml <%= render :partial => ''foo'' %> Or from another controller: <%= render :partial => ''some_controller/foo'' %>> But why are you trying to include a navbar into the rhtml file? Aren''t > you using your layouts folder? The layouts in your project should take > care of everything for you.Because it is on multiple pages, but not all? There are many reasons for keeping it encapsulated. -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
Hi. thanks for your reply. To answer your question, being new to ruby I''m still a little unsure of how far I can go. I created the navbar with fireworks, so I have a directory of images with the .htm file containing the code. I''m just not sure how to include that code in the views rendered by Rails. Also, when you said you can render partials, did you mean render the partials from within a different file: E.g, I have a standard PHP file, included navbar, images, text, and so on, and then I have render_partial => _showbookings ? Or did you mean the other way around? If so, how would I code it so that the contents of that html file are included within the given view (for example let''s say http://localhost:3000/bookings/show linked to the show.rhtml file) would show my included navbar? Hussein. -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---