I actually was just in a similar situation, but found
that using the sibling's page parts worked better in
my situation as opposed to the parent's.
I wanted to have a "slideshow" section of my site and
used the very cool page_page_types that Dror created
to allow uploading of photos. I however wanted all of
the children tabs (page parts) of that section to have
the "attachment" attribute, so when I created a new
page under that section it automatically would be
created with an attachment page part (along with a few
other custom page I wanted parts). It was easy to code
up something in the page_controller.rb to just create
the @page.parts to use the parent of the new page you
were creating. For example:
if request.get?
@page.parent.parts.each do |part|
@page.parts << PagePart.new(:name =>
part.name)
end
end
This might do what some people have asked for. But, I
then thought about it more and realized... Ideally, in
my situation, I don't want to have the attachments (or
other custom parts) page part types on the slideshow
SECTION page. This didn't make sense to have to put my
page parts on the parent. I just needed some way to
say only that all of the children of that section
should have a predefined set of page parts. The
thought then was to make it so when a page is created
it would use it's SIBLING's page parts. The only way I
could think of to do this was to grab the first child
of the parent that is being created and use the parts
from that. For example, some code like this:
if request.get?
if @page.parent != nil && @page.parent.children[0]
!= nil
@page.parent.children[0].parts.each do |parts|
@page.parts << PagePart.new(:name =>
parts.name, :page_part_type_id=>
parts.page_part_type_id)
end
else
default_parts.each do |name|
@page.parts << PagePart.new(:name => name)
end
end
end
You have to create one page with the types you want,
but then others created in that section will have the
same as the first one defined.
I appologize for the long post. Just wanted to share
my thoughts and see what others thought about this. I
think there is some merit to having some sort of
"inherit" attributes on creating a page so all the
children of that page would have the attributes
defined, but just wanted to point out in some cases
you might not want to have to set the page part on the
parent and instead want to base the new page off it's
siblings. I'm also looking for maybe a good generic
way to do this since as of right now I have hacked the
core page_controller.rb to get this to work. Plus, as
you can see my code only goes 1 level up, so ideally
if we were to have it use the parent's, it should
recurse up to the root page.
Keep up the great work on Radiant!
Thanks,
Justin
--- "John W. Long" <[EMAIL PROTECTED]> wrote:
> Krzysztof Szafranek wrote:
> > What I'd like to see in Radiant is parts'
> inheritance...
>
> Mmm, that's an interesting thought. So when you
> create a new page it
> would have blank parts defined for every one of it's
> parent's parts? You
> could then delete them or add others, but it would
> inherit it's parent's
> parts at creation time?
>
> --
> John Long
> http://wiseheartdesign.com
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site:
> http://lists.radiantcms.org/mailman/listinfo/radiant
>
____________________________________________________________________________________
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates
(http://voice.yahoo.com)
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant