You recently made a purchase of Multi Tenant Saas module of Bagisto. Now, you might want to do some tweaks in the theme for a particular tenant but when you directly make changes in some velocity theme files you end up messing it for other tenants also. So today in this tutorial, we’ll see the correct way how one can make changes in front end for a single tenant without messing other tenants. Let’s get started.
Basically there can be two ways to make changes in specific tenants.
Its a very easy process through which you can make changes on most of your stuff on home front. Let’s see how it works.
Step 1: Go to Admin Panel of your tenant.
Step 2: Go to settings -> Channel -> edit.
Step 3: You can change most of the settings like the logo or the home page content or the themes etc.
Now comes the real part. Imagine you want to create another theme or want to change the colors used in the current theme i.e velocity.
So in order to understand that, we are taking a situation.
A situation where you want to change the color of header or navbar used in velocity theme.
Here, I have created a package with a name webfonts and created the admin settings from where, the admin can change the colors and stuff of front.
If you want to learn how to create admin settings: https://devdocs.bagisto.com/1.x/packages/add_menu_in_admin.html
Create a style.php file inside:
Package Name -> src -> Resources -> views -> style.php
What will style.php do ?
In this file we will pick the colors of particular places for from end from admin (which we have created recently), and change those colors in css with a condition.
This is my style.php
Here, I have picked the colors from admin with a condition where if the colors from admin are not set, It will take the default colors.
Next step is to fire an event where your theme will pick up these settings whene the theme will be loaded on server.
Create an EventServiceProvider.php file in the same package:
Package Name -> Providers -> EventServiceProvider.php
In the above code I have rendered an event and called my style.php file.
This is one very easy step and most of you have already know how to do that.
You just have to create a service provider and add your event service provider file in it.
And you are done, Now you can change the colors of header and navbar for a single tenant.
Note: While creating the configs and saving it to the database, always use an extra column to store the current company ID, So it will only work for your current tenant.
The process through which the super admin can make changes in a particular tenant is almost same as shown above for Tenant’s Admins
But need to make some tweaks.
Create super admin credentials with the fields:
Now we need to create Migration and Database in order to save our configured theme settings for a particular tenant.
We have a domain with the name bagsaas.com
We’ll create sub domains for tenants:
At the same time, no changes will be made to site2.bagsaas.com
Check out the screenshot below.
So that’s how you can make changes in one tenant without affecting the another one.
Be the first to comment.
Subscribe to our newsletter for exclusive growth strategies, special offer, latest news and tutorials.