Jump to content
swampmusic

using multi-instances with dynamic multi-sites problem

Recommended Posts

Having a problem with a basic multi-site instance.

The multi-sites are dynamically created and run as sub-domains and all is ok with them. They are created during a sign up process by end users.

During the sign up process - once the new site & db has been created, I had planned to load the new site instance and add a new user to it, using code similar to this..

$newSiteInstance = new ProcessWire($path, $newSiteUrl);
 
$u = $newSiteInstance->users->add($sitename);
$u->pass = $pass;
$u->email = $email;
$u->addRole('content-viewer');
$x = $newSiteInstance->users->save($u);

 This won't work in the registration script. It throws an error ... "SQLSTATE[42S02]: Base table or view not found".

However, if I halt the script, load the new site incognito/other browser, then continue the script, all works perfectly.

So $newSiteInstance = new ProcessWire($path, $newSiteUrl); doesn't seem to work for me unless a site has already been loaded in a browser or instantiated somehow.

I am missing something here ? Does a site need to be bootstrapped before new instance will work on it ? 

Sorry, pretty new to this php/PW arena.  Having fun though :-)

Any ideas folks ?

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By snck
      Hello,
      in a project I use the multi-instance feature of ProcessWire to get content from another ProcessWire instance which is kind of a "database". I do not modify the external content. For a slider I want to store references to the "database" in an InputfieldPage. To get the available pages I use the following code in my ready.php:
      $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'kub_highlight_artworks') { // Server path to the PW installation $path = '/var/www/vhosts/.../'; // The root URL for the PW installation $url = 'https://.../'; // Create a new ProcessWire instance $db = new ProcessWire($path, $url); $event->return = $db->pages->find("template=artwork, sort=title"); } }); Outputting and selecting the external pages works perfectly fine, but unfortunately the selected pages do not get saved when I save the page.
      Can someone point me into the right direction how to make this work? Are there any internal checks whether the page exists in the current instance that prevent saving the values?
      Best,
      Flo
    • By joeck
      Hi there,
      I'm trying to have a multi-site (multiple databases) setup on a IIS (Microsoft) server.
      I know that IIS is not officially supported by ProcessWire but customer is insisting on IIS.
      I get an 500 Error when trying to access the sub-domain/other processwire site.
      Did somebody do this before or is it not possible at all to have a multi-site setup on IIS?
      Thanks
    • By joeck
      Hi Everyone,
      I was playing around with the ProcessWire command-line script sitemap.sh (https://processwire.com/docs/front-end/include/)
      I currently have a multi-site setup (with separate databases).
      -> site
      -> site-other
      The sitemap works but it shows only the pages from the default site directory. How can I get the sitemap of the site-other directory?
      Here is my working code that prints the sitemap of 'site':
      #!/usr/bin/php <?php namespace ProcessWire; include("index.php"); // bootstrap ProcessWire function listPage($page, $level = 0) { echo str_repeat(" ", $level) . $page->title . "\n"; foreach($page->children as $child) { listPage($child, $level+1); } } listPage($pages->get("/")); // start at homepage I tried including index.config.php instead of index.php but that didn't help...
    • By kongondo
      Using ProcessWire's in-built multi-site support (option #1 here), is it possible to bootstrap the various sites? To bootstrap ProcessWire, the only requirement is to include /path/to/processwire/index.php/. In option #1, there is only one index.php. So, including index.php defaults to bootstrapping the main site (i.e. the site at /site/. Is it possible to bootstrap the other sites, i.e. site-dogs, site-cats, site-birds, etc? I've searched the forums but nothing relevant comes up.
      Thanks.
    • By yinken
      Hi everyone,
      I am using ProcessWire to run a multi-site environment using the Multisite module by Soma.
      It's working great with one small caveat. It always defaults to the English version of the site. So when you access the base url (somedomain.com) it always redirects to somedomain.com/en/. In my particular case I need it to go to the Germany version somedomain.com/de/.
      Some things I've tried:
      I've tried fiddling around with the AutoDetectLanguage module to have a user redirected based on the detected browser language - didn't work. I've also tried messing with a module that changes what the default homepage is (smth like DefaultHomepage I believe), but that also had no affect. I used the Redirect module to have the root ('/') redirected to specific language URL ('/de/) - also didn't work My guess is that it has something to do with the default language in the setup which is set to english, but I am not sure.
      Has anyone else come accross this issue?
      Thanks in advance.
×
×
  • Create New...