Formerly icon indicating copy to clipboard operation
Formerly copied to clipboard

Error when multiple siteUrls in config

Open nilsenpaul opened this issue 9 years ago • 3 comments

If Craft's config-file has an array of siteUrls, for localization purposes, line 259 of the SubscriptionService throws an error on submission:

$result = str_replace("{siteUrl}", craft()->config->get("siteUrl"), $result);

nilsenpaul avatar Oct 15 '15 12:10 nilsenpaul

It seems that Formerly has no support for multiple languages yet.

xtrasmal avatar Oct 21 '15 14:10 xtrasmal

yeah sorry we have no need for multi languages at this point so can't justify the time involved with my bosses. If anyone wants to add this that would be awesome

wiso1234 avatar Oct 22 '15 21:10 wiso1234

This is actually pretty easy to resolve assuming:

  1. you are using the locale set-up recommended by P&T - see http://buildwithcraft.com/docs/multi-environment-configs
  2. you are declaring your locale via a global variable, eg CRAFT_LOCALE. For example, in my site root (index.php) I am declaring a global variable based on a switch conditional against $_SERVER['SERVER_NAME'] - see http://buildwithcraft.com/docs/php-constants

In formerly/services/Formerly_SubmissionsService.php you need to add a conditional based on your locale to line 260:

if (count(craft()->config->get("siteUrl")) > 0) $result = str_replace("{siteUrl}", craft()->config->get("siteUrl")[CRAFT_LOCALE], $result);
else $result = str_replace("{siteUrl}", craft()->config->get("siteUrl"), $result);

Will see if can sort a pull request for this.

cole007 avatar Nov 10 '15 15:11 cole007