Can i load different sprinkle for each domain

Hello,

i have many domains that access the UserFrosting,
every domain is a different site but with the same management…

can i load a different sprinkle for each domain separately?

Thank you in advance for helpers :slight_smile:

Probably the easiest thing to do is to have a common Sprinkle with the shared functionality, and then site-specific Sprinkles that implement the unique features/styles of each site. This is actually what I do with my company sites https://bloomingtontutors.com and https://collegeparktutors.com.

there is no other way to manage the loaded sprinkle within the PHP ?

If you really want, you can manually instantiate the SprinkleManager (see https://github.com/userfrosting/UserFrosting/blob/master/app/system/UserFrosting.php). But, I strongly recommend that you simply have multiple, separate instances of UF running on your server, and implement a common Sprinkle that you can add to all of your installations with git submodule.

ok…

i will do this in my code:

index.php

switch($_S ERVER[‘HTTP_HOST’]) {
case “domain_1.com”: $sprinkles_file = “sprinkles_domain1.json”; break;
case “domain_1.com”: $sprinkles_file = “sprinkles_domain1.json”; break;
default: $sprinkles_file = “sprinkles.json”; break;
}

$uf = new UserFrosting($sprinkles_file);

app/system/UserFrosting.php

class UserFrosting
{
private $sprinkles_file;

  public function __construct($sprinkles_file = "sprinkles.json")
  {
        $this->sprinkles_file = $sprinkles_file;
        /* old code */
  }

  public function setupSprinkles($isWeb = true)
  {
        /* old code */

        $schemaPath = \UserFrosting\APP_DIR . $this->sprinkles_file;

        /* old code */
  }

}

Can you add this to the main project ? (or in same other way)

This is good feature for advanced users like you and me that need this…
this will make the work on our common websites easier

Actually, I agree, sprinkles.json should probably not be hardcoded here, or anywhere else for that matter. Could you open an issue on GH for this?