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;









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

                    Tamil (spriik) Luke uk diar | Nawigatjuun

                    Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                    Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?