OllieMackJames Posted February 11, 2018 Share Posted February 11, 2018 How can I clone the homepage? I have a small site where I use the repeatermatrix to build the page, lots of work to build each page, but it makes for very nice looking pages. When I grow the site, I need the homepage to become another page, so I want to clone it or move it. I can copy any other page, but just not the home page, so the core clone module is not the way. How can I do this? Thanks! Link to comment Share on other sites More sharing options...
dragan Posted February 11, 2018 Share Posted February 11, 2018 I'm not sure I understand your setup. Cloning your home page would mean cloning every single child page as well. Are you sure you want that? You could try the following: go to the home template settings, open the family tab, and check "can this template be used for new pages" -> yes (default is no). I would really strongly advise against doing that, but it could be (technically) possible. I would re-think your whole setup in the first place. If you manage to clone your homepage, then quickly change the template of your cloned page, and reset the family settings of the home-template, and after you have deleted all the child clones you don't need anymore, and everything still works as expected... OK. But really, that's not "PW-like" / recommended way to build a site. 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted February 11, 2018 Author Share Posted February 11, 2018 @dragan, thanks for chiming in. The site is a small site, and the home page template is used on other pages as well. It is a salessite, where I started with one major salespage as the homepage, but now want to add another page as home page, that is why I want to clone the homepage rather than rebuild it with around 30 carefully built repeater matrix fields on it. "PW-like" to me means to be able to do what is needed. It would be great if there was an option to specify which page to be used for the homepage. How simple can that be? I do not like wordpress (to put it mildly) but I have a few sites running on it, just to try out stuff that I then port to processwire. This particular site is a port of some funcionality that we ported from thrive themes, which now allows me to build very good salespages with an great amount of variety, through the use of repeater matrix. But once a page is built it is so much easier to clone it rather than rebuild by hand. Oh, BTW your suggestion did not work, even with all the settings you specified - which are standard on my site anyways, I do not have the option to clone the homepage. Anybody else know how to do this 1 Link to comment Share on other sites More sharing options...
Robin S Posted February 12, 2018 Share Posted February 12, 2018 @OllieMackJames, your setup makes sense to me. But you cannot clone the Home page because there can only be a single page at the top of the page hierarchy. Instead you need to move the Home page contents to another page... Add a new template with the same fields as your home template (use the "Duplicate fields used by another template" option when adding it). Create a new page using this template. Now check out @adrian's Admin Actions module which has two built-in actions that you'll find useful to move the content from the existing Home page to this new page: 1. Copy Repeater Items to Other Page 2. Copy Field Content to Other Page Another tip: If when setting up a site you know that you will later want to turn the Home page into an internal page you can make it easier by using an internal page to hold your Home page content. Let's say this internal page has the ID 1234. Don't publish this page (so it won't be accessible on the front-end). At the top of home.php (your home template file) you put... $page = $pages(1234); ...and now wherever you do $page->title etc in home.php you will get the content from page 1234. Later when you are ready to switch the Home page you can populate your home page with content (or repeat the steps above for a different unpublished internal page), remove/change the $page assignment in home.php, and publish page 1234. 2 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted February 12, 2018 Author Share Posted February 12, 2018 @Robin S, very big thanks! I installed the Admin Actions, but see it does not work with the repeater matrix, only repeaters, otherwise that would be a good option. I like your second suggestion and will go and try that. I'll add a home page template with just one visible page select field that then allows me to select the underlying page that will be used for the homepage per your code above, that sounds like it wold jus do what I want to do. Gotta love this amazing thing called Processwire! Combined with an awesome group of people around it helping each other getting things done. So once again, @dragan thanks for your input and @Robin S you for putting me in the direction of a solution I will use! 2 Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2018 Share Posted February 13, 2018 @OllieMackJames and others - @Robin S was kind enough to enhance AdminActions to support RepeaterMatrix fields: 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted February 13, 2018 Author Share Posted February 13, 2018 THANKS! @adrian and @Robin S You coding giants truly rock and are amazing! I wish I could reciprocate but man alive I wouldn't even know where to begin if it comes to coding. Am I ever glad to have found this wonderful processwire engine with it's amazing community of giants that allow us all to move forward. Best wishes to you coding giants out here! 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted February 13, 2018 Author Share Posted February 13, 2018 started a new topic about the necessary code to add to template here: Link to comment Share on other sites More sharing options...
thetuningspoon Posted August 10, 2020 Share Posted August 10, 2020 Temporarily comment out the following line in Page.php: throw new WireException("You may not modify '$key' on page '{$this->path}' because it is a system page"); This will allow you to clone the home page via the API: $homePage = $pages->get('/'); $pages->clone($homePage, $homePage, false); 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now