Jump to content

Copying a site but link database to first site


bramwolf
 Share

Recommended Posts

Hi Guys,

I got the request to copy a site I created in processwire, which shouldn't be too much of a problem, but also to have to content ( Pages, templates and field contents ) loaded from the original site so that they stay in synch. With site one dictating the content on the second. How would I go about realizing that? would I be stuck with continuously importing data from site 1 via cvs export/import or XML feed, or could I link my second site to the database of the first?   

Also I would like to make small changes in the template of of the second site. For instance Site one hosts a Hotel listing, with price € 300, and on the second Site I would like to change it to "Price on request" with an email link. Could I adjust template files on the hosting of site 2 and still load data from site 1?

Hope somebody can help :) Thanks guys!

 

Link to comment
Share on other sites

The question is if the content is really the same. If it is, and the changes are just in the PHP templates, you could use PW's built-in multi-site support and (untested):

  • Copy the PW installation to the second site's webroot
  • Delete the "site/modules" directory and link it to the original site's modules directory
  • Do the same for site/assets/files
  • Do the same for the wire directory
  • Delete the contents of the site/assets/cache and site/assets/sessions directories
  • Edit site/config.php, set $config->sessionName to something unique from the first site (the default is "wire", so perhaps something like "wiresite2") and adapt $config->httpHosts to match your new site's hostname(s)

All done.

This assumes that both sites are hosted on the same server with the web server running as the same user. If that isn't the case, you will have to either

  • adapt file system permissions, group memberships and umasks (same server, different users)
  • or keep your own copies of wire, modules and files directories around and sync these from the first site (in that case, you best disallow admin access in the copy through .htaccess)

If you want the copy to have some unique content, the task gets a bit harder, and you might have to use some kind of export/import mechanism or a feed like you wrote. But you could cover some unique content with individual templates that only have a matching PHP template on one of the sites, and there are ways to hook into Page::viewable and decide in PHP code (site/ready.php) whether certain pages can be viewed in the current site (e.g. if a page has an ancestor that hast the current hostname or a wildcard in a certain field).

  • Like 1
Link to comment
Share on other sites

Thanks man! :) 

the idea js to use a different domain/server/user entirely. The content should be exactly the same, it basicly a rebranded version of site 1. And the only changes are going to be in the template files. Ask for price instead of price from database. Which of your solutions do you think would work best for this case?

 

thanx again :)

Link to comment
Share on other sites

@bramwolf, you can adapt the approach suggested here, which avoids having to duplicate anything other than the template files:

So you would:

  • set domain 2 to point to the server that hosts the website at domain 1
  • allow domain 2 as an alias in the hosting configuration (see the alias options in cPanel, Plesk, etc)
  • in /site/config.php check which domain is being accessed and set the templates path/url accordingly
  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...