Jump to content

Share content across 2 sites


Peter Knight
 Share

Recommended Posts

Hi guys

Is it possible to have a PW site display content from another PW site?

I've been reading about ProcessWire's Multi-site options and I don't think either is a way forward for me.

Both PW sites are separate installs with separate databases but crucially they are on the same VPS. So I'm hoping that's a good thing.

Basically, Site A has approx 100 reviews consisting of these fields

  • Reviewer name
  • Review
  • Date

Instead of setting up the fields onto Site B and duplicating work and creating 100 pages, I want to *somehow* get site B to use a selector to fetch the necessary content from Site A.

In future, if I need to update the reviews, I can goto the 'source' Site A to do this.

 

Link to comment
Share on other sites

I wouldn't explore multi-site anymore. You could spit out a feed from site A and read it on site B. You could even import them into site B. I am on mobile right now, but we do this quite regularly so could post an example when I am in the office. RSS, XML, lots of options. 

  • Like 1
Link to comment
Share on other sites

3 minutes ago, cb2004 said:

I wouldn't explore multi-site anymore. You could spit out a feed from site A and read it on site B. You could even import them into site B. I am on mobile right now, but we do this quite regularly so could post an example when I am in the office. RSS, XML, lots of options. 

Thanks. That all sounds good. 

Link to comment
Share on other sites

This should be quite easy using the bootstrapping feature of PW: https://processwire.com/docs/front-end/include/

Oops, wrong keyword, actually I wanted to link to multi-instance use of pw like @kongondo does in the next post ? 

You could then grab data from one install and show it on the other instance wherever you want.

4 hours ago, Peter Knight said:

they are on the same VPS. So I'm hoping that's a good thing.

Yes, for bootstrapping multi-instance that's a good thing ? 

  • Like 2
Link to comment
Share on other sites

I just tried out this multi-instance approach and Tracy returns this error:

E_COMPILE_ERROR: 
Cannot declare class ProcessWire\FieldtypeRepeater, because the name is already in use on line: 31 in 
/home/devsite/www/prototypen/instance-2/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module

Compile Error: Cannot declare class ProcessWire\FieldtypeRepeater, because the name is already in use (line 31 of /home/devsite/www/prototypen/instance-2/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module) 

This error message was shown because: site is in debug mode. ($config->debug = true; => /site/config.php). Error has been logged.
$site = new ProcessWire('/home/devsite/www/prototypen/instance-2/', 'https://prototypen.devsite.com/instance-2/');
$home = $site->pages->get(1);
$homeUrl = $home->httpUrl;
$homeTitle = $home->title;
echo "<a href='$homeUrl'>$homeTitle</a>";

Path and URL are correct, and both PW sites are on the same server. I'm calling it from a PW 3.0.108 installation. Instance 2 is 3.0.126.

Weird.

Link to comment
Share on other sites

  • 5 years later...
On 3/8/2019 at 3:47 PM, dragan said:

I just tried out this multi-instance approach and Tracy returns this error:

E_COMPILE_ERROR: 
Cannot declare class ProcessWire\FieldtypeRepeater, because the name is already in use on line: 31 in 
/home/devsite/www/prototypen/instance-2/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module

Compile Error: Cannot declare class ProcessWire\FieldtypeRepeater, because the name is already in use (line 31 of /home/devsite/www/prototypen/instance-2/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module) 

This error message was shown because: site is in debug mode. ($config->debug = true; => /site/config.php). Error has been logged.
$site = new ProcessWire('/home/devsite/www/prototypen/instance-2/', 'https://prototypen.devsite.com/instance-2/');
$home = $site->pages->get(1);
$homeUrl = $home->httpUrl;
$homeTitle = $home->title;
echo "<a href='$homeUrl'>$homeTitle</a>";

Path and URL are correct, and both PW sites are on the same server. I'm calling it from a PW 3.0.108 installation. Instance 2 is 3.0.126.

Weird.

Hey, did you ever find a solution to this?

I'm suffering with the same issue and can't find any solution to resolving this across the forum.

For context, both sites are using ProcessWire 3.0.229. When I connect to another site on 3.0.210 it works fine.

EDIT: Sadly I had to give up on this because I simply could not find the root of the issue - I can connect to other sites without issue but not this particular one. In the end I used file_get_contents and RIPEMD160 to create a hash from the e-mail address used on both sites (plus a secret token). That is working well.

Link to comment
Share on other sites

  • 3 months later...

Also, had some issues with the Processwire multi-instance sites using the latest versions and ProcessWire 3.0.123  'Compile Error: Cannot declare class FieldtypeRepeater, because the name is already in use (line 30 of...'.

The error message was on the sub-domain that also had more complexity with fields and modules.

Our code was bootstrapped on the sub-domain and included Processwire namespace too.

As new install of the latest version worked, but actual sites with additional fields and modules did not? Further investigation and debugging highlighted that on a new install the 'Repeater' module is not installed and therefor does not cause an error?

However, on the working sites renaming the folder 'FieldtypeRepeater' located in the 'wire' folder (/wire/modules/Fieldtype/FieldtypeRepeater) caused Tracy Debugger to error instead. Removing this module in addition to renaming folder ' 'FieldtypeRepeater' allowed everything to work as expected.

You have to login before renaming the core module 'FieldtypeRepeater' and ignore the admin messages whilst you access the multi-instance data and create pages on the sub-domain.

Not a very elegant work around, but if you only need to read and write the data temporarily at least it is possible now.

Hopefully, this may help someone else work out how to fix it properly?

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

×
×
  • Create New...