-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drupal multilingual with path prefix, template url #567
Comments
I noticed exactly the same issue on a multilingual site. |
Not Drupal 9 specific, I get the same symptom on a Drupal 7 multilingual with path prefix as well. On a parallel note - a version of this has been an issue for a while, I have the following aliases in my apache config that works around some parts of this problem: Alias /en/sites/default/files/ /var/www/drupal/web/sites/default/files/ |
The alias is indeed a quick fix. Thanks for posting this temporary solution. |
Hello, thanks for reporting it, detected the same problem in D9 multilingual, I think its not saved in the database, the problem is how its called the url here: https://github.com/veda-consulting-company/uk.co.vedaconsulting.mosaico/blob/2.11/api/v3/MosaicoTemplate.php#L81 A possible solution could be using the settings variable that contains the url: diff --git a/api/v3/MosaicoTemplate.php b/api/v3/MosaicoTemplate.php
index 5477cdad8..6fb748495 100644
--- a/api/v3/MosaicoTemplate.php
+++ b/api/v3/MosaicoTemplate.php
@@ -78,7 +78,7 @@ function civicrm_api3_mosaico_template_get($params) {
if (_civicrm_api3_mosaico_template_getDomainFrom($baseTemplateURL)) {
$urlParts = parse_url($baseTemplateURL);
$templatePath = $urlParts['path'];
- $currentURL = CRM_Utils_System::baseURL() . $templatePath;
+ $currentURL = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/') . $templatePath;
} else {
$currentURL = $baseTemplateURL;
}
Maybe this can be a general solution, awaiting further comments. |
Same here, Drupal 9 with language prefix in path + Mosaico 2.11.1676403645. In our use-case, whilst the mod_alias workaround will enable the loading of a existing template and for it to be edited, after saving it again the next time the template is loaded we get a 404 again as the path has had an additional language prefix added. This happens on every save (ie /en/en/en/en/...ad infinitum..../sites/default/files/[etc]). ie works around until resaved (in this case). Maybe we have a different problem, but this is the context in which it has been noted. I don't know the extension well,, but agree that amending the file as per CsarRamos diff seems to resolve the loading issues, so +1 for a patch/fix, especially when the function concerned seems quite limited in scope. Thank you! |
Also seen it today in a D7 multilanguage CiviCRM 5.60. |
Can also confirm with 2.11, d9 and multi language active. If Multi language isn't needed it can also be deactivated here: /admin/config/regional/language/detection. Simply turn off the URL detection method and mosaico works as intended after a cache clear. |
I was working on client site and can't disable multilanguage in url so i found temporary and fast solution in comenting some lines in api/v3/MosaicoTemplate.php
|
Solution from CsarRamos is working for us. Debian 11, Apache2, php 7.4 File: api/v3/MosaicoTemplate.php b/api/v3/MosaicoTemplate.php From: $currentURL = CRM_Utils_System::baseURL() . $templatePath; :-) |
Ubuntu 22.04 + plesk Nginx applied [CsarRamos] patch to get civicrm/mosaico-template-list to show again, as before i got an api error Same on D9.5xx with php 8.1 But my versafix-1 is still showing up GREY..... any hints? |
@Rar9 I had the same situation. When I ran this SQL:
I saw that many of my template paths as stored in the database already had the language prefaced. See below. Template 42 is fine, template 43 has the unwanted
To fix this, I ran this query. Note that the preface might be different for you, mine is
|
with SELECT id, metadata from civicrm_mosaico_template; This works
this only shows gray with Mosaico Version 3.3.1697392242 - See Screenshot also path looks good.
Console Error - Ignor Url as it was form other debug |
I am confused by a few things in the mosaicotemplate api functions:
Even if I hack it to think it's not multisite, I still run into another problem, which seems to be more related to #624. |
I created #629 as a PR with a suggested fix. People testing it would be appreciated! |
Similar to #543
On a Drupal 9 multilingual site using path prefixes, the 'template' value stored in the metadata field of civicrm_mosaico_template is getting messed up when the template is saved, rendering it unuseable (i.e., when trrying to use the template, you get the dreaded mosaico "blank" (all grey) screen.
On a mono-lingual site, I can see that the template used to be stored as a url, unescaped, and it's now stored with forward slashes escaped and the domain removed. That's nice as far as being able to swap domains for a dev copy!
What's happening for multilingual sites with a path prefix (and possibly with the related issues including the one above) is that the template url is getting saved as
en\/\/sites\/default\/files\/civicrm\/ext\/uk.co.vedaconsulting.mosaico\/packages\/mosaico\/templates\/versafix-1\/template-versafix-1.html
There are two issues here:
https://domain.org/en/en//sites/default/files/civicrm/ext/uk.co.vedaconsulting.mosaico/packages/mosaico/templates/versafix-1/template-versafix-1.html
This could be resolved in either how the template value gets saved, or how it gets used. Since it's broken in use both for using a template and for editing it, I think the main issue is how it's getting stored.
My quick reading of the changes here: https://github.com/veda-consulting-company/uk.co.vedaconsulting.mosaico/pull/529/files
is that urls are being constructed by combining the civicrm base url and the path, which doesn't always work (i.e. when the cms is fairly sophisticated with the request routing).
The text was updated successfully, but these errors were encountered: