newbie question

0 views
Skip to first unread message

tomcloyd

unread,
Apr 21, 2008, 2:56:49 PM4/21/08
to Webby
Greetings! I'm launching full speed into learn Webby - very pleased so
far. Is much more than I'd hoped for, and also far more clever than
the thing I was going to write for myself before learning of this
software. I'm learning a lot just studying it.

At this point I have a simple question which I've not yet been able to
clearly answer (my study time have been a bit constrained). I want to
be able to handle what I call hierarchies of templates. A simple
example:

Page A is composed of
Element 1, which is composed of
Element 1.1
Element 1.2
Element 2, which is composed of
Element 2.1
Element 2.2
Element 2.3
Element 3

I want to be able to change any of the elements, and have the change
be passed up to the final composited page. I assume this is possible.
Is it?

Thanks! I'm very eager to get started with all this.

Tom C.

Tim Pease

unread,
Apr 21, 2008, 5:09:12 PM4/21/08
to webby...@googlegroups.com

There are two ways to go about doing this.

The first method assumes that all the items listed above will result
in rendered pages that the user can navigate to. In this case, you
would first find the appropriate "Element" page by name and then
render it in the parent page ...

<% page = @pages.find( :title => 'Element 1.1' ) %>
<%= page.render %>

The above snippet would appear in the text file for the "Element 1"
page. Something similar would appear in the "Page A" page. The clever
programmer would put the desired page names in an array, loop over the
array and find the pages, and then render each page.


The second method assumes that on "Page A" should end up as a rendered
page that the user can navigate to. In this case, all the "Element"
pages would exist as partials in the content folder. A partial is any
page in the content folder whose filename starts with and underscore _.

In "Page A" then, you would have a snippet of code like this ...

<%= render_partial('element_1') %>

This will find the partial file "_element_1.txt" in the content folder
and render it's contents into "Page A". In the _element_1.txt file,
you would have something like this ...

<%= render_partial('element_1_1') %>
<%= render_partial('element_1_2') %>

Again, you could put the partial names in an array and iterate a block.

Hope this helps.

Blessings,
TwP

tomcloyd

unread,
Apr 22, 2008, 6:54:19 AM4/22/08
to Webby
Wonderful! Both your replies are useful to me - the second was
actually what I was after, however.

Thanks so very much, both for your informative replay and for
you exceptional development work. I'll be starting work on three
websites this evening, using Webby. Should be fun...

t.
Reply all
Reply to author
Forward
0 new messages