Newbie question about rendering partials and rhtml

Hi,

im not sure if i am on the right path here, so i figured i would ask.

Basically, all of my pages have the same header and footer, and i was
wondering if there was some way i could reference this from the rhtml
file?

from what i have read on partial and template rendering, this is done in
the
controller, but in my case, the header and footer are static, so there
is no
logic. Basically, I am just trying to minimize the number of places i
need
to edit in case i make a change to my header or footer (i.e. if i add a
link, i would really like to just update 1 file, rather than do it in
all of
my views).

Is this possible? thanks!

View this message in context:
http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10324965
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

Have a look at layouts, that is precisely what they are for. For
example, if
you create an html skeleton, call it application.rhtml and place it in
the
layouts folder (in views/), the app will call it by default. In the area
where you want the controller-generated output to go, simply place this
call:

<% yield %>

and the magic will take place.

On 5/4/07, gmoniey [email protected] wrote:

Is this possible? thanks!

View this message in context:
http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10324965
Sent from the RubyOnRails Users mailing list archive at Nabble.com.


http://www.web-buddha.co.uk

Hi Dave,

I read up on layouts, (

Radar – O’Reilly )

and it made me wonder why you cant specify a specific layout inside an
action? i tried placing the: layout “standard-layout” inside one of my
action def’s, but i ended up with an error.

it this not possible?

Dave G. wrote:

and the magic will take place.

wondering if there was some way i could reference this from the rhtml
of


http://www.web-buddha.co.uk


View this message in context:
http://www.nabble.com/newbie-question-about-rendering-partials-and-rhtml-tf3692733.html#a10332020
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

The “layout ‘standard-layout’” call is a class method call that sets the
layout for the whole controller.

To specify a specific layout for an action, pass it to render:

def fooaction

do something

render :layout => ‘super-special-layout’
end

b

thanks for clearing that up…i have another question…this may be
more of a design question…our existing website has 2 templates, and
we determine which one to show based on screen size, which is
determined through javascript…i.e.

now i am trying to determine how to do this…basically all of my
actions behave the same, except they have a different layout…

but i am a bit confused…it doesnt seem like i can do this on the
server side…i.e. in the controller…or in the .rhtml file…so
should i redirect with a id specifying which template? (i.e. set the
window.location to specify the id in the url, and then base the
template on that?

im not sure if i have been very clear…so if this is confusing…let
me know…and i’ll try and clear it up…

I guess it depends how much of the difference between the two templates
is
presentational is handled by css. If so, the javascript can still do
it’s
thing. The rhtml layouts should only contain structural information (ie
html/xhtml). Clarify a little more?

On 5/5/07, [email protected] [email protected] wrote:

    {

actions behave the same, except they have a different layout…

and it made me wonder why you cant specify a specific layout inside an
in the

On 5/4/07,gmoniey[email protected] wrote:

file?
to edit in case i make a change to my header or footer (i.e. if i
http://www.nabble.com/newbie-question-about-rendering-partials-and-rh
Sent from the RubyOnRails Users mailing list archive at Nabble.com.


http://www.web-buddha.co.uk


http://www.web-buddha.co.uk

gmoniey wrote:

Hi,

im not sure if i am on the right path here, so i figured i would ask.

Basically, all of my pages have the same header and footer, and i was
wondering if there was some way i could reference this from the rhtml
file?

In the view you can do this

<%= render “blog/header” %>

blah lbah

<%= render “blog/footer” %>

PS: I would rather create one layout which include header and footer :slight_smile:

the two layouts are actually very different…different images,
different static text, different tables, div’s etc…

i have been thinkin about this more and more…and it seems like the
best way to do it would be something like this:

and have the action handle which template will be shown from there on
out (since this really only need to be figured out the first time the
page loads), however…im worried about the case where the user wanted
to go back to the homepage…i.e. http://www.mysite.com, i would need
a way to ensure that the javascript is run again…