Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Duplicating pages in 'onPagesInitialized' hook

Started by Muut Archive 11 years ago · 2 replies · 201 views
11 years ago

Are there any plugins or examples of how to duplicate a page, manipulate its frontmatter content, and insert it into the pages collection?

11 years ago

I don't think this has been done in any plugin. We have plugins that create a page object and set the current page to that, but nothing that dynamically creates a virtual page from another page, modifies it, and then injects that back into the pages structure to be used by other things. This is probably doable, but you would be the first to try it!

You could start off by seeing if clone() works for pages. You would definitely have to change the unique parts (path, slug, etc) or you will get collisions with the other pages.

11 years ago

I just looked and we do have a copy method on the Page class that is used by the admin plugin. You might be able to use that to do what you need.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4044 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago