Radiant Duplicate extension
May 2nd, 2007
Sometimes, using radiant to build a site, I need to generate many pages with the same page parts and the same contents, aside a few things..instead of copy all the page parts and all the contents I created the Radiant Duplicate extension. It adds a new action (duplicate) near the ‘Add child’ button:






May 11th, 2007 at 12:00 am
It was necessary to fix the duplicate extension because the “Copy whole tree” option wasn’t recursive enough. It went only 2 generations deep. Here’s the revised method:
def duplicate_children source_page, dest_page, recursive = false
source_page.children.each do |page|
new_page = duplicate_page page, dest_page
if recursive
page.children.each do |sub_page|
new_page = duplicate_page sub_page, new_page
duplicate_children sub_page, new_page, true
end
end
end
end
May 11th, 2007 at 12:03 am
Second issue (relates more to Radiant’s design):
The addition of the “Duplicate” link to the standard Radiant interface only works if other extensions aren’t competing to modify that interface. For example, in the latest 0.6.1 version the Reorder extension modifies this interface. As a result I don’t get the Duplicate link. I had to modify the Reorder extension to include the Duplicate link.
Anyway, your extension was *much needed* and very welcome!! Thank you.
May 11th, 2007 at 12:35 pm
Hey Mario, thank you very much for your patch..I know the second issue..but it will be better in Radiant 0.6.5..I’m waiting for this version to improve my extensions..tnx again!