Having multiple development stages, I'd like to keep some magento configurations in a file, and not in the database, so i can have my development version and the production version in sync.
So i need to put in a different place the "base url", that is not the database, because I'd like to export it from production to development
is it possible?
It's possible:
<default>
<web>
<unsecure>
<base_url>https://foo.dev/</base_url>
</unsecure>
<secure>
<base_url>https://foo.dev/</base_url>
</secure>
</web>
</default>
<websites>
<ws_code>
<web>
<unsecure>
<base_url>http://ws.foo.dev/</base_url>
</unsecure>
<secure>
<base_url>https://ws.foo.dev/</base_url>
</secure>
</web>
</ws_code>
</websites>
<stores>
<store_code>
<web>
<unsecure>
<base_url>http://store.foo.dev/</base_url>
</unsecure>
<secure>
<base_url>https://store.foo.dev/</base_url>
</secure>
</web>
</store_code>
</stores>
However if anyone ever saves (or has saved) the System > Configuration > Web section in the admin, the values in your config file for that scope will not apply.
There are a couple of strategies for protecting your entries
Use the file-based config approach and disable access to the Web section via admin user roles (for all users). Caveat: you'll need to provide all of the configuration options in your config.
Use setup scripts (PHP) to write the base_url entries to the core_config_data table, and protect them from being overwritten via an observer configured under the adminhtml event area for the core_config_data_save_before event.
You could also combine the observer protection from strategy #2 with the file-based config from strategy #1.
Related
We're trying to leverage Azures deployment slots for an Umbraco site we've built.
By default Umbraco uses a DSN defined in the connectionStrings sections of the web.config and we want it to use the connection string for the deployment slot it's sitting in.
What we've tried
Azure deployment slots put all defined app settings (and connection strings) into environment variables and to access them we can use Environment.GetEnvironmentVariable() which works but there doesn't seem to be a way to tell Umbraco to do this.
So in OnApplicationInitialized() (in /App_Code/Core/UmbracoAppStart.cs) we loaded the connectionstring section from the web.config, grabbed the connstr from env vars, added the DSN to the connectionstring section and saved.
The correct connection string is grabbed and stored but this seems to recycle the app (due to a web.config change) and thus we just get timeouts. (Or Umbraco XML cache errors, or it takes 20 mins to load the page).
I know you can store the appsettings and connectionstrings sections in separate files. But the file attribute (that doesn't cause a recycle if the referenced file is changed) doesn't work on the connectionStrings section - only the configSource attribute and that DOES recycle if changed.
(from: ASP.NET web.config: configSource vs. file attributes)
Help
Has anyone found a way around this?
We simply need to get Umbraco to use the deployment slot connection string - not the one in webconfig.
I'm even willing to copy and paste blindly at the moment without understanding how it works - and I hate doing that :). But that's what happens when people agree when the client wants to go live just before Christmas...
You don't need to do any code to use Azure connection string or the app settings. Just give them the same keys/names as you have on your web.config and they will be used instead.
So if you have this on your web config:
<add name="umbracoDbDSN" connectionString="Server={server};Initial Catalog={db};Persist Security Info=False;User ID={user};Password={password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=300;" providerName="System.Data.SqlClient" />
Your slot configuration should be this:
To replace an app setting just use the same key. So for this:
<add key="umbracoUseSSL" value="false" />
You'd use this:
If you want the setting to be slot specific you have to activate the Slot setting checkbox.
I integrated active directory with sitecore and it works perfect, now i am trying to write patches for the config changes. Sections <membership defaultProvider="sitecore" hashAlgorithmType="SHA1"> and <roleManager defaultProvider="sitecore" enabled="true"> are changed for connection setting to AD. When i try to write config patch for this section, this section is not built at run time. But the domains section works, i mean the patch i created for this section works and writes to web.config at runtime. I observed a difference here Domains section is under <Sitecore>, <membership> and <roleManager > are in <system.web> section. Is this the reason that these are not included in web.config? can we write patches for those sections only under <sitecore>?
Any ideas are appreciated.
Thanks.
You can only patch elements within the /configuration/sitecore element.
Refer this post:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/All-About-Web-config-Include-Files-with-the-Sitecore-ASPNET-CMS.aspx
I think you have to use config transforms as mentioned by leandro.
I assumming you are using Visual Studio ¿? You must specify in what are you working.
If so, you need create a transform file for the build configuration that you need, for example, one config for every environment or publish type.
Try a look at this:
http://msdn.microsoft.com/en-us/library/vstudio/dd465318%28v=vs.100%29.aspx
I need to change the alfresco explorer and share url using proxy. How to change the url?
My current url is http://System1:8080/alfresco, http://System1:8080/share
I need to change to http://kroxx, http://wiks
You need to configure both servers to produce the correct links. This configuration should go in your alfresco-global.properties, making sure that each WAR file accesses its relevant configuration entries:
alfresco.context=
alfresco.host=kroxx
alfresco.port=80
alfresco.protocol=http
share.context=
share.host=wikis
share.port=80
share.protocol=http
You most likely need also to change your Share configuration in order for CMIS to properly produce links to your public Alfresco URLs. The following goes to your share-config-custom.xml:
<alfresco-config>
<config evaluator="string-compare" condition="Server">
<server>
<scheme>http</scheme>
<hostname>kroxx</hostname>
<port>80</port>
</server>
</config>
</alfresco-config>
With some custom logic I have added a template for my web config in my Asp Mvc 4 application. When I need to modify the web.config file I am editing the template file for it and the changes are replaced in the web config file when I run the application. The problem is that when I add a package via nuget which needs to modify the web config file I am losing those settings as everything is overriden from my template file. Is there a way to somehow force the nuget packages to modify some custom xml file instead of the original web config file. For example, to modify mytemplate.xml instead of web.config.xml.
I am very new in this area and couldn't find a solution for my problem. As far as I understand packages that need to modify the web.config file come with web.config.transform file that merges the required fields and my only solutions is to manually replace the settings added to my web config file by the package into the template file. Is there another solution ? Thanks!
You are using your web.config file to do two different things:
Static configuration for nuget packages
Dynamic configuration for your site
web.config files allow you to define some of your settings in an external file and import them - e.g.
<configuration>
...
<appSettings configSource="appSettings.config" />
...
</configuration>
This is appSettings.config:
<appSettings>
<add key="umbracoDbDSN" value="..."/>
<add key="DefaultInstanceName" value="..."/>
<add key="aspnet:MaxHttpCollectionKeys" value="..."/>
</appSettings>
It's unlikely that you need to completely re-generate your web.config every build, probably only specific sections - if these don't clash with your installed packages then this approach would give you the flexibility your application needs.
OR PLAN B
packages.config lists all of the active packages in your solution
Packages store their web.config settings in a local file:
/packages/package/content/Web.config.transform
Can you extend the process that builds your web.config file to:
Enumerate the active packages
Check for a content/Web.config.transform file
Merge those files into your web.config build pipeline
I can't see any way of re-configuring nuget to push the configuration into a different file.
I have a number of settings that are currently in the config.yml file.
Going forward I want to be able to develop an interface where administrators will be able to update these settings, so I want to be able to manage these settings through the database.
How would I be able to load these settings from the database into Symfony2 and where and when would I load them?
Cheers
Adam
There's a cookbook article that explains roughly how to do this (albeit briefly), in reference to loading in settings externally from Drupal. The basic idea is to do something like this in your config (example is yml):
# app/config/config.yml
imports:
- { resource: parameters.php }
then in parameters.php you can do whatever you need to to get your config, and set it as follows:
$container->setParameter('my.db.parameter', $value);
(taken from the cookbook, slightly modified).
Take a look at the UnifikDatabaseConfigBundle. It creates a database structure that enable configuration of Symfony parameters straight from the database.