[J4] Error use relative path for styles, scripts. #31714
Replies: 8 comments
-
Normally the SEF system plugin calculates the correct path and transforms them to absolute paths if it finds a relative one for href, src and other ones. |
Beta Was this translation helpful? Give feedback.
-
It's good that the SEF plugin does this. but it is not clear why the I don't even know why up to version 4 of Joomla, this behavior is considered the norm.
|
Beta Was this translation helpful? Give feedback.
-
First of all, stop crying, and get hold of yourself. It not end of the world. Second, existing |
Beta Was this translation helpful? Give feedback.
-
Of course "JUri", but this is in PHP . And what api should I use to get the address in JS? i know what the current behavior is, which is exactly what i wanted to discuss here,. |
Beta Was this translation helpful? Give feedback.
-
easy: JHtml::_('behavior.core'); var sysPaths = Joomla.getOptions('system.paths'),
basPath = sysPaths.base + '/';
As I said, it need to be discussed, I have no idea. |
Beta Was this translation helpful? Give feedback.
-
I checked your code in different sites and servers
|
Beta Was this translation helpful? Give feedback.
-
Hard to say, maybe issue with installation, joomla-cms/libraries/src/WebAsset/AssetItem/CoreAssetItem.php Lines 38 to 47 in 690bf5f upd: I just looked your sites, |
Beta Was this translation helpful? Give feedback.
-
@Fedik , @ReLater , @dziudek , @pollen8
I forgot about this hack. And so I was confused as to why half of my sites don't have this problem. It turns out that the problem is everywhere. I do not ask how to get around this problem, since I have already written that it can be solved by specifying the home path to the site or passing the path to the page as an attribute. But it's all hacks and crutches.
|
Beta Was this translation helpful? Give feedback.
-
Tell me why the
<base>
tag repeats the address of the site itself?https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
The tag description says, the address is used to indicate relative links. Why if the site address "http://joomla-site.com/menuitem/article" then the
<base>
tag also has an address "http://joomla-site.com/menuitem/article"? relative links of styles, scripts, and images don't work! What if the CMS is installed in a child folder of the domain "http://site.com/joomla/" here, in general, no relative link will work, scripts and styles with relative paths will not be loaded. When developing, I got out of the situation only with absolute paths. But not everything has to sculpt an absolute path?<link href="/css/style.css" >
and
<script src="/js/script.js">
these paths should work even when the CMS is installed in a subfolder of the domain. http://site.com/joomla/ and the enabled seo mode should not be a hindrance to the operation of the site.. even the admin panel must have the same base address, since scripts and styles are used from the media folder of the application.
Beta Was this translation helpful? Give feedback.
All reactions