cancel
Showing results for 
Search instead for 
Did you mean: 

Load an additional css style sheet according to the subdomain

SOLVED

Load an additional css style sheet according to the subdomain

Hello,

 

I would like to find a way to load an additional css style sheet according to the subdomain.

This css will overhide some rules of the theme css.

There will be many subdomains.

 

I was thinking in doing it with a plugin but as it will be my first plugin, I don't know how to do it and if it is really the best solution.

 

Can someone if my approach is a good one and if possible guide me on how to start?

 

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Load an additional css style sheet according to the subdomain

Hello @melghazi 

 

The steps you have mentioned that is correct !

 

Also as per my experience with Magento on a code level there is no limit to generate no of websites,store or store-views.

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

View solution in original post

10 REPLIES 10

Re: Load an additional css style sheet according to the subdomain

Hello @melghazi 

 

Agenda behind to do this - is to keep design change on separate domain ? So both domain have different design ? that is the purpose ? or anything else ?

 

Can you elaborate more on this.

 

if issue solved,Click Kudos & Accept as Solution

Re: Load an additional css style sheet according to the subdomain

Hello Dave,

 

I will try to explain the concept as clear as possible.

 

There is the main shop, for example: www.shopmagento.com.

It has a theme and 4 store views (one per language).

 

We will create many subdomains as alias of www.shopmagento.com:

  • subdomain1.shopmagento.com
  • subdomain2.shopmagento.com
  • subdomain3.shopmagento.com
  • ...

All these subdomains will have exactly the same content as the main shop (www.shopmagento.com).

 

What I want to achieve, is that to be able for each subdomain, to modify the main design by for example overriding css rules and maybe if possible make some layout change by adding or removing content.

 

Is it more clear?

 

Thanks

 

 

 

 

Re: Load an additional css style sheet according to the subdomain

Hi @melghazi 

 

Yes i got your point.

 

Previously we have done the same kind of functionality.

 

Where we have created a separate theme for each store and that sub-domain is assigned to that specific store.

 

so all the subdomain css store theme will be same like the main store - but if you want to change its layout or css or anything you can directly change it to that theme directly and it will effect on that specific store.

 

So instead of creating plugin - you can directly change css for that specific store/sub-domain and it will works for you.

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Load an additional css style sheet according to the subdomain

Hello Dave,

 

Thank you for your reply.

 

To give you more details, the thing is that some content of the subdomains websites like the logo, the css colors and maybe the products categories displayed for this subdomains would be loaded dynamically by a request to another application.

 

I have thought that creating a module or plugin to achieve that would be better than going directly editing the corresponding template file. What do you think?

 

 

Re: Load an additional css style sheet according to the subdomain

Hello Dave,

 

Before you reply to my previous message, I made some research and find this post:

https://community.magento.com/t5/Just-Ask-Alan/magento-2-maximum-number-of-websites-and-stores-suppo...

 

Which is similar to what I am trying to achieve.

My concern was about a limitation of number of websites which could affect the performance.

Do you have any advices on that?

 

I guess the process will be for each subdomain to:

1- create a website and link it to the subdomain url

2- create the store and store view

3- create a new theme that extend my main theme (for the modification)

4- assign the logo and extended theme to the new website

 

Is it correct?

 

Thanks,

Mehdi

Re: Load an additional css style sheet according to the subdomain

Hello @melghazi 

 

The steps you have mentioned that is correct !

 

Also as per my experience with Magento on a code level there is no limit to generate no of websites,store or store-views.

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Load an additional css style sheet according to the subdomain

Thank you again for your help!

Re: Load an additional css style sheet according to the subdomain

Hello @melghazi 

 

Glad to know that you have resolved your issue ! Happy to help and keep helping Smiley Happy

if issue solved,Click Kudos & Accept as Solution

Re: Load an additional css style sheet according to the subdomain

Hi Dave,

 

As discussed, I have created the new website, store and store view for the subdomain.

In the admin I have updated the base url for this new element with the subdomain url.

 

The subdomain was still redirected to the main domain.

So I tried to edit the htaccess with what I have found but without success.

 

Here is what I have tried:

 

RewriteCond %{HTTP_HOST} test\.website-store\.ch [NC]
RewriteRule .* - [E=MAGE_RUN_CODE:mbs_000001]
RewriteCond %{HTTP_HOST} test\.website-store\.ch [NC]
RewriteRule .* - [E=MAGE_RUN_TYPE:website]

and also:

 

SetEnvIf Host test\.website-store\.ch MAGE_RUN_CODE=mbs_000001
SetEnvIf Host test\.website-store\.ch MAGE_RUN_TYPE=website

The mbs_000001 is the code I have defined for this new website.

 

Do I forgot something?

Is it how to do it or am I wrong?

 

Thanks,

Mehdi