As a developer of an application that requires multiple environments, each with a different base url, I would like the ability to specify my Default Base URL in settings.php.
Currently this module uses the State API for this setting which allows me to set a unique Default Base URL in each environment without risk of override via a config import. However, I must set this state manually for each environment via the module's settings page or via CLI. Allowing an override of this setting in settings.php using the $settings variable will allow me to define an environment's unique Default Base URL along with all of its other unique settings.
Comment | File | Size | Author |
---|---|---|---|
#16 | xmlsitemap-2999856-16.patch | 3.17 KB | pifagor |
| |||
#12 | 2999856-11.patch | 3.18 KB | Rob Holmes |
| |||
#10 | 2999856-10.patch | 2.86 KB | Rob Holmes |
#4 | xmlsitemap-allow_base_url_override_in_settings_php-2999856-3.patch | 4.5 KB | Arrow |
|
Comments
Comment #2
ArrowThe attached patch allows you to set your default base URL by setting xmlsitemap_base_url in your settings.php like so:
This will override any value previously set during installation of the module or set via the module settings page. It also disables the Default Base URL field on the settings page.
Comment #3
ArrowComment #4
ArrowFixed a line error in the patch.
Comment #5
MerryHamster CreditAttribution: MerryHamster at Skilld for Skilld commentedI use "version": "1.0.0-alpha2" and patch #4 doesn't work for me.
So I created the patch from #4 for one.
Comment #6
MerryHamster CreditAttribution: MerryHamster at Skilld for Skilld commentedComment #8
MerryHamster CreditAttribution: MerryHamster for Skilld commentedComment #9
MerryHamster CreditAttribution: MerryHamster for Skilld commentedAdded a little fix for the patch from #5 for 'alpha2' version.
Comment #10
Rob Holmes CreditAttribution: Rob Holmes commentedRe-roll
Comment #12
Rob Holmes CreditAttribution: Rob Holmes commentedReinstate missing use Drupal\Core\Site\Settings;
Comment #13
KarenS CreditAttribution: KarenS at Lullabot commentedWe've run into this as well. We need to be able to deploy a number of new sites automatically from configuration and we don't want to have to manually configure this each time.
Comment #14
KarenS CreditAttribution: KarenS at Lullabot commentedSeems to work fine and tests pass.
Comment #15
Liam MorlandInstead of:
$base_url_override ? TRUE : FALSE;
You can do:
(bool) $base_url_override
Comment #16
pifagorComment #17
alex_optimComment #18
pifagorComment #20
pifagorComment #22
leymannxNice work! Finally I found this one when I was halfway through changing the base URL to
$GLOBALS['base_url']
everywhere. I wonder if this still wouldn't be a nice addition that if the Settings was omitted to fallback to$GLOBALS['base_url']
. By that the value could also simply be passed from the--uri
option using Drush.drush -y xmlsitemap:rebuild --uri=example.com