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?
Do you celebrate paying your mortgage off with colleagues?
Functions where the sum of its partial derivatives is zero
What happened to the SEV instruction on the 6502?
Rational Number RNG
Why do the new Star Trek series have so few episodes in each season?
How do I search for a package?
Is it OK to call company for more details about a job post (not an application)?
What's the short and accented note at the very end of a song called?
How can a signal be both periodic and random?
How to delete music as it's being played
Does recycling lead to less jobs?
Program to print the multiple occurrence of numbers in a list
What can players do while waiting for a troll to regenerate?
Is the EU Settlement Scheme legal?
What does "crank old Sabbath" refer to?
Why does hashing public keys not actually provide any quantum resistance?
Why do the Romance languages use definite articles, when Latin doesn't?
What's the origin of the trope that dragons used to be common but aren't any more?
Does a troll die if its maximum hit points is zero?
How are hillsides farmed?
Why is there a strong link between education and voting Remain?
Is Jupiter bright enough to be seen in color by the naked eye from Jupiter orbit?
Confusion in PID loop?
Can someone interview their sibling?
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