Site-specific value for an appsetting in a multisite solutionHow to separate site configurations among managed multi sitesHow to best use Roles and Domains with Multi-site SSOCross-site links not resolving correctly in RTE fields on multi-site environmentSitecore multisite , multiple country/region and multilanguage support implementationHow Sitecore 9 Forms Module is featured for Multi-Site and Multi-Lingual?SC_ANALYTICS_GLOBAL_COOKIE domain name in multisiteHow to create multisite solution in SXA 1.6 with different themesEXM in multisite environmentIn Sitecore JSS Multisite we will have an jss app for each Site?
How is "slaad" pronounced?
How can a signal be both periodic and random?
How can I increase the rate of regeneration in humans without the possibility of tumors developing?
Why is Microwaved mac & cheese burnt where they touch?
Can I reproduce this in Latex
What happened to the SEV instruction on the 6502?
Optimus and the comparative and superlative uses of adjectives in Latin
Are commoners actually this squishy?
What can I wear to avoid getting frisked and crotch searched by TSA at the airport?
Why doesn't the nucleus have "nucleus-probability cloud"?
How to distinguish between different instruments in a classical orchestra?
Why are one-word titles so dominant in books, film, and games?
Best way to drill square tubing (Without drill press)
How to write 2**n - 1 as a recursive function?
What is the purpose of polls published by the organization that they are asking about which have leading/confusing questions?
Is there a name for the phenomenon of false positives counterintuitively outstripping true positives
Is there an unambiguous name for the social/political theory "liberalism" without "leftist"?
As tourist in China do I have to fear consequences for having publicly liked South Park
Company asks (more than once) if I can involve family members in project
RX vs TX operation in Software UART
What is the easiest way to list all the user:group found in a tarball?
Articles at the beginning of sentences in scientific writing
Copying files: Does Windows write to disk if files are identical
What Fruit Am I?
Site-specific value for an appsetting in a multisite solution
How to separate site configurations among managed multi sitesHow to best use Roles and Domains with Multi-site SSOCross-site links not resolving correctly in RTE fields on multi-site environmentSitecore multisite , multiple country/region and multilanguage support implementationHow Sitecore 9 Forms Module is featured for Multi-Site and Multi-Lingual?SC_ANALYTICS_GLOBAL_COOKIE domain name in multisiteHow to create multisite solution in SXA 1.6 with different themesEXM in multisite environmentIn Sitecore JSS Multisite we will have an jss app for each Site?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I have a multisite solution with two sites, xyz.com and abc.com. For a given appsetting variable I want to have different values. Is it something which is possible out of the box in Sitecore?
The patch file will overwrite the variable and hence cannot use it.
multisite
add a comment
|
I have a multisite solution with two sites, xyz.com and abc.com. For a given appsetting variable I want to have different values. Is it something which is possible out of the box in Sitecore?
The patch file will overwrite the variable and hence cannot use it.
multisite
add a comment
|
I have a multisite solution with two sites, xyz.com and abc.com. For a given appsetting variable I want to have different values. Is it something which is possible out of the box in Sitecore?
The patch file will overwrite the variable and hence cannot use it.
multisite
I have a multisite solution with two sites, xyz.com and abc.com. For a given appsetting variable I want to have different values. Is it something which is possible out of the box in Sitecore?
The patch file will overwrite the variable and hence cannot use it.
multisite
multisite
edited May 29 at 13:33
Peter Mortensen
1172 bronze badges
1172 bronze badges
asked May 29 at 4:23
rdhaundiyalrdhaundiyal
4442 silver badges13 bronze badges
4442 silver badges13 bronze badges
add a comment
|
add a comment
|
3 Answers
3
active
oldest
votes
It can be done using two different techniques:
Technique 1
Inside the site tag you can add your custom attribute like the below code:
<site patch:before="*[@name='website']"
....
customSetting="XXX"
/>
You can patch this file for multiple sites and you can get this value like this
Context.Site.Properties["customSetting"]
Technique 2
You can add one field in the SiteRoot template and get the value from that field.

thanks, i was trying to use targethostname the same way but didn't realize that i can use a custom field as well. will try this one.
– rdhaundiyal
May 29 at 6:39
add a comment
|
When you say that you have a multisite solution, I understand you have multiple sites defined in the Sitecore <sites> section like this:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
/>
You can add any custom properties to every site definition like:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
myCustomValue="custom value XYZ"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
myCustomValue="custom value ABC"
/>
And then read it in the code
var value = Context.Site.Properties["myCustomValue"];
add a comment
|
Instead of AppSetting you can keep such site specific values in Sitecore.
To add settings to the site, modules should define templates which can be added as base templates to the site root item for the project layer module, or add settings items inside the site hierarchy.
For example, the Feature/Accounts module defines an AccountsSettings template which is assigned to the Site Root template in the Project/Habitat module.
The module uses the site hierarchy to find the settings items for the module.
public virtual Item GetAccountsSettingsItem(Item contextItem)
Item item = null;
if (contextItem != null)
item = contextItem.GetAncestorOrSelfOfTemplate(Templates.AccountsSettings.ID);
item = item ?? Context.Site.GetContextItem(Templates.AccountsSettings.ID);
return item;
Yes, I was doing that earlier but that has its own issue, when we restore db to lower environment that get copies to lower environment as well which i want to avoid.
– rdhaundiyal
May 29 at 5:09
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "664"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f19003%2fsite-specific-value-for-an-appsetting-in-a-multisite-solution%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
It can be done using two different techniques:
Technique 1
Inside the site tag you can add your custom attribute like the below code:
<site patch:before="*[@name='website']"
....
customSetting="XXX"
/>
You can patch this file for multiple sites and you can get this value like this
Context.Site.Properties["customSetting"]
Technique 2
You can add one field in the SiteRoot template and get the value from that field.

thanks, i was trying to use targethostname the same way but didn't realize that i can use a custom field as well. will try this one.
– rdhaundiyal
May 29 at 6:39
add a comment
|
It can be done using two different techniques:
Technique 1
Inside the site tag you can add your custom attribute like the below code:
<site patch:before="*[@name='website']"
....
customSetting="XXX"
/>
You can patch this file for multiple sites and you can get this value like this
Context.Site.Properties["customSetting"]
Technique 2
You can add one field in the SiteRoot template and get the value from that field.

thanks, i was trying to use targethostname the same way but didn't realize that i can use a custom field as well. will try this one.
– rdhaundiyal
May 29 at 6:39
add a comment
|
It can be done using two different techniques:
Technique 1
Inside the site tag you can add your custom attribute like the below code:
<site patch:before="*[@name='website']"
....
customSetting="XXX"
/>
You can patch this file for multiple sites and you can get this value like this
Context.Site.Properties["customSetting"]
Technique 2
You can add one field in the SiteRoot template and get the value from that field.

It can be done using two different techniques:
Technique 1
Inside the site tag you can add your custom attribute like the below code:
<site patch:before="*[@name='website']"
....
customSetting="XXX"
/>
You can patch this file for multiple sites and you can get this value like this
Context.Site.Properties["customSetting"]
Technique 2
You can add one field in the SiteRoot template and get the value from that field.

edited May 29 at 13:32
Peter Mortensen
1172 bronze badges
1172 bronze badges
answered May 29 at 6:03
Swati GuptaSwati Gupta
1,3384 silver badges18 bronze badges
1,3384 silver badges18 bronze badges
thanks, i was trying to use targethostname the same way but didn't realize that i can use a custom field as well. will try this one.
– rdhaundiyal
May 29 at 6:39
add a comment
|
thanks, i was trying to use targethostname the same way but didn't realize that i can use a custom field as well. will try this one.
– rdhaundiyal
May 29 at 6:39
thanks, i was trying to use targethostname the same way but didn't realize that i can use a custom field as well. will try this one.
– rdhaundiyal
May 29 at 6:39
thanks, i was trying to use targethostname the same way but didn't realize that i can use a custom field as well. will try this one.
– rdhaundiyal
May 29 at 6:39
add a comment
|
When you say that you have a multisite solution, I understand you have multiple sites defined in the Sitecore <sites> section like this:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
/>
You can add any custom properties to every site definition like:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
myCustomValue="custom value XYZ"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
myCustomValue="custom value ABC"
/>
And then read it in the code
var value = Context.Site.Properties["myCustomValue"];
add a comment
|
When you say that you have a multisite solution, I understand you have multiple sites defined in the Sitecore <sites> section like this:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
/>
You can add any custom properties to every site definition like:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
myCustomValue="custom value XYZ"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
myCustomValue="custom value ABC"
/>
And then read it in the code
var value = Context.Site.Properties["myCustomValue"];
add a comment
|
When you say that you have a multisite solution, I understand you have multiple sites defined in the Sitecore <sites> section like this:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
/>
You can add any custom properties to every site definition like:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
myCustomValue="custom value XYZ"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
myCustomValue="custom value ABC"
/>
And then read it in the code
var value = Context.Site.Properties["myCustomValue"];
When you say that you have a multisite solution, I understand you have multiple sites defined in the Sitecore <sites> section like this:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
/>
You can add any custom properties to every site definition like:
<site
name="xyz"
hostName="xyz.com"
rootPath="/sitecore/content/site-a"
startItem="/home"
myCustomValue="custom value XYZ"
/>
<site
name="abc"
hostName="abc.com"
rootPath="/sitecore/content/site-b"
startItem="/home"
myCustomValue="custom value ABC"
/>
And then read it in the code
var value = Context.Site.Properties["myCustomValue"];
edited May 29 at 13:32
Peter Mortensen
1172 bronze badges
1172 bronze badges
answered May 29 at 6:00
Marek MusielakMarek Musielak
14.9k1 gold badge19 silver badges41 bronze badges
14.9k1 gold badge19 silver badges41 bronze badges
add a comment
|
add a comment
|
Instead of AppSetting you can keep such site specific values in Sitecore.
To add settings to the site, modules should define templates which can be added as base templates to the site root item for the project layer module, or add settings items inside the site hierarchy.
For example, the Feature/Accounts module defines an AccountsSettings template which is assigned to the Site Root template in the Project/Habitat module.
The module uses the site hierarchy to find the settings items for the module.
public virtual Item GetAccountsSettingsItem(Item contextItem)
Item item = null;
if (contextItem != null)
item = contextItem.GetAncestorOrSelfOfTemplate(Templates.AccountsSettings.ID);
item = item ?? Context.Site.GetContextItem(Templates.AccountsSettings.ID);
return item;
Yes, I was doing that earlier but that has its own issue, when we restore db to lower environment that get copies to lower environment as well which i want to avoid.
– rdhaundiyal
May 29 at 5:09
add a comment
|
Instead of AppSetting you can keep such site specific values in Sitecore.
To add settings to the site, modules should define templates which can be added as base templates to the site root item for the project layer module, or add settings items inside the site hierarchy.
For example, the Feature/Accounts module defines an AccountsSettings template which is assigned to the Site Root template in the Project/Habitat module.
The module uses the site hierarchy to find the settings items for the module.
public virtual Item GetAccountsSettingsItem(Item contextItem)
Item item = null;
if (contextItem != null)
item = contextItem.GetAncestorOrSelfOfTemplate(Templates.AccountsSettings.ID);
item = item ?? Context.Site.GetContextItem(Templates.AccountsSettings.ID);
return item;
Yes, I was doing that earlier but that has its own issue, when we restore db to lower environment that get copies to lower environment as well which i want to avoid.
– rdhaundiyal
May 29 at 5:09
add a comment
|
Instead of AppSetting you can keep such site specific values in Sitecore.
To add settings to the site, modules should define templates which can be added as base templates to the site root item for the project layer module, or add settings items inside the site hierarchy.
For example, the Feature/Accounts module defines an AccountsSettings template which is assigned to the Site Root template in the Project/Habitat module.
The module uses the site hierarchy to find the settings items for the module.
public virtual Item GetAccountsSettingsItem(Item contextItem)
Item item = null;
if (contextItem != null)
item = contextItem.GetAncestorOrSelfOfTemplate(Templates.AccountsSettings.ID);
item = item ?? Context.Site.GetContextItem(Templates.AccountsSettings.ID);
return item;
Instead of AppSetting you can keep such site specific values in Sitecore.
To add settings to the site, modules should define templates which can be added as base templates to the site root item for the project layer module, or add settings items inside the site hierarchy.
For example, the Feature/Accounts module defines an AccountsSettings template which is assigned to the Site Root template in the Project/Habitat module.
The module uses the site hierarchy to find the settings items for the module.
public virtual Item GetAccountsSettingsItem(Item contextItem)
Item item = null;
if (contextItem != null)
item = contextItem.GetAncestorOrSelfOfTemplate(Templates.AccountsSettings.ID);
item = item ?? Context.Site.GetContextItem(Templates.AccountsSettings.ID);
return item;
edited May 29 at 13:32
Peter Mortensen
1172 bronze badges
1172 bronze badges
answered May 29 at 5:01
S.KazmiS.Kazmi
4802 silver badges15 bronze badges
4802 silver badges15 bronze badges
Yes, I was doing that earlier but that has its own issue, when we restore db to lower environment that get copies to lower environment as well which i want to avoid.
– rdhaundiyal
May 29 at 5:09
add a comment
|
Yes, I was doing that earlier but that has its own issue, when we restore db to lower environment that get copies to lower environment as well which i want to avoid.
– rdhaundiyal
May 29 at 5:09
Yes, I was doing that earlier but that has its own issue, when we restore db to lower environment that get copies to lower environment as well which i want to avoid.
– rdhaundiyal
May 29 at 5:09
Yes, I was doing that earlier but that has its own issue, when we restore db to lower environment that get copies to lower environment as well which i want to avoid.
– rdhaundiyal
May 29 at 5:09
add a comment
|
Thanks for contributing an answer to Sitecore Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f19003%2fsite-specific-value-for-an-appsetting-in-a-multisite-solution%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown