Page 1 of 1
[Solved] relative links adding http:// [see code fix]
Posted: Sat Aug 01, 2020 8:39 pm
by labeshops
any idea why links in information page are no longer relavite links for multistores? I used to be able to (v2.2) use "/login" as a link for example and oc would automatically make it "storeurl/login" with the storeurl being the store it was clicked on, but it doesnt seem to do that anymore in v3? It is working with links in the footer, but not on info pages like
www.allwicca (dot) com/affiliate-program. It was adding http:// to the /login link.
Re: multistore links on info pages?
Posted: Sat Aug 01, 2020 9:37 pm
by JNeuhoff
any idea why links in information page are no longer dynamic for multistores?
No, because your details are too vague to be of a useful help.
For a start, what exact links are you talking about, on what information page? OpenCart version? Any other extensions? Any URL?
Re: multistore links on info pages?
Posted: Sat Aug 01, 2020 9:44 pm
by labeshops
JNeuhoff wrote: ↑Sat Aug 01, 2020 9:37 pm
any idea why links in information page are no longer dynamic for multistores?
No, because your details are too vague to be of a useful help.
For a start, what exact links are you talking about, on what information page? OpenCart version? Any other extensions? Any URL?
As I already said, I am using v3 ( v3.0.3.2 as stated in my signature to be exact), and creating links on an info page. The sample URL is in my original post too so not sure what you were reading.
Re: multistore links on info pages?
Posted: Sat Aug 01, 2020 10:08 pm
by JNeuhoff
OK, I got it now. It's a known summernote editor issue, with a possible fix proposed here:
https://github.com/summernote/summernote/issues/1037
Your links shouldn't be auto-prefixed with the 'https://' nor 'http://' when you want relative URLs.
Re: multistore links on info pages?
Posted: Sat Aug 01, 2020 10:58 pm
by labeshops
ah yeah, that is what it is doing. I will try the fix, thanks.
Re: multistore links on info pages?
Posted: Sat Aug 01, 2020 11:03 pm
by labeshops
Okay, I figured out the fix. Thanks JNeuhoff for pointing me to it.
Edit file admin/view/javascript/summernote/summernote.js
Find around line 4342:
Code: Select all
$.each(anchors, function (idx, anchor) {
// if url doesn't match an URL schema, set http:// as default
linkUrl = /^[A-Za-z][A-Za-z0-9+-.]*\:[\/\/]?/.test(linkUrl) ?
linkUrl : 'http://' + linkUrl;
$(anchor).attr('href', linkUrl);
if (isNewWindow) {
$(anchor).attr('target', '_blank');
} else {
$(anchor).removeAttr('target');
}
});
Replace with:
Code: Select all
$.each(anchors, function(idx, anchor) {
// if url doesn't match an URL schema, set http:// as default
// only if onCreateLink callback not specified.
if (options.onCreateLink) {
linkUrl = options.onCreateLink(linkUrl);
} else {
linkUrl = /^[A-Za-z][A-Za-z0-9+-.]*\:[\/\/]?/.test(linkUrl) ?
linkUrl : 'http://' + linkUrl;
}
$(anchor).attr('href', linkUrl);
if (isNewWindow) {
$(anchor).attr('target', '_blank');
} else {
$(anchor).removeAttr('target');
}
});
Re: multistore links on info pages?
Posted: Mon Aug 03, 2020 6:49 pm
by paulfeakins
labeshops wrote: ↑Sat Aug 01, 2020 11:03 pm
Okay, I figured out the fix.
Don't forget to add [SOLVED] to the beginning then.