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;









2

















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.










share|improve this question


































    2

















    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.










    share|improve this question






























      2












      2








      2


      1






      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.










      share|improve this question

















      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






      share|improve this question
















      share|improve this question













      share|improve this question




      share|improve this question








      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























          3 Answers
          3






          active

          oldest

          votes


















          5


















          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.



          Enter image description here






          share|improve this answer




























          • 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


















          2


















          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"];





          share|improve this answer



































            2


















            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;






            share|improve this answer




























            • 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













            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
            );



            );














            draft saved

            draft discarded
















            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









            5


















            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.



            Enter image description here






            share|improve this answer




























            • 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















            5


















            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.



            Enter image description here






            share|improve this answer




























            • 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













            5














            5










            5









            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.



            Enter image description here






            share|improve this answer
















            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.



            Enter image description here







            share|improve this answer















            share|improve this answer




            share|improve this answer








            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

















            • 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













            2


















            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"];





            share|improve this answer
































              2


















              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"];





              share|improve this answer






























                2














                2










                2









                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"];





                share|improve this answer
















                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"];






                share|improve this answer















                share|improve this answer




                share|improve this answer








                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
























                    2


















                    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;






                    share|improve this answer




























                    • 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
















                    2


















                    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;






                    share|improve this answer




























                    • 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














                    2














                    2










                    2









                    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;






                    share|improve this answer
















                    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;







                    share|improve this answer















                    share|improve this answer




                    share|improve this answer








                    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


















                    • 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



















                    draft saved

                    draft discarded















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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









                    Popular posts from this blog

                    Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

                    Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?

                    apt-get update fails to fetch files, “Temporary failure resolving …” errorWhy does apt-get fail to resolve the mirror?Apt-get update not working in Ubuntu 16.04 “temporary failure resolving”Ubuntu 16.04 Server updates - Temporary failure resolving 'ro.archive.ubuntu.com'“Failed to fetch… Temporary failure resolving…” when trying to installTemporary failure resolving ca.archive.ubuntu.comUbuntu 18.04 sudo apt update doesn't work (Failed to Fetch)apt-get error: “Temporary failure resolving 'archive.ubuntu.com' ”“Temporary failure resolving us.archive.ubuntu.com” Live USB rescueTemporary failure resolving 'es.archive.ubuntu.com' on Ubuntu Server15.04 Server fails to update with failed to fetch temporary failure resolving errorsCan't install software from Software CenterApt-get failed to fetch from Ubuntu server with error code 404“Unable to connect” error with apt-get: possible proxy?v12.10 can't apt-get update111: Connection refused when trying apt updateSudo apt-get update