?
avatar korenevskiy
korenevskiy
18 Dec 2020

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.

avatar korenevskiy korenevskiy - open - 18 Dec 2020
avatar joomla-cms-bot joomla-cms-bot - change - 18 Dec 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Dec 2020
avatar korenevskiy korenevskiy - change - 18 Dec 2020
The description was changed
avatar korenevskiy korenevskiy - edited - 18 Dec 2020
avatar ReLater
ReLater - comment - 18 Dec 2020

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.

avatar korenevskiy
korenevskiy - comment - 18 Dec 2020

It's good that the SEF plugin does this. but it is not clear why the <base> tag contains an address with an error.
I wrote an Ajax component in JS. everything worked until the client said that ajax does not work in his subfolder of the site. And then I realized that with the help of the script I can not find out the address of the main page.
i had to pass the url parameter to find out about it in the js script.
do you think this is normal?
Suppose the CMS corrects absolute paths for itself. It seems like the CMS itself has a defect and itself has a crutch to solve this defect. But why should component developers suffer from this defect?

I don't even know why up to version 4 of Joomla, this behavior is considered the norm.

  1. This is a violation of the specification.
  2. There is no need to use the <base> tag because the SEF plugin tries to fix it by ignoring its purpose.
  3. the <base> tag is not useful in principle, it contains false information.
  4. i think everyone is satisfied with this meaningless behavior, because no one uses this tag.
    Many sites do not use the <base> tag at all. Google.com does not use this tag. Why do we need it then?
    Let's make it right.
    The sef plugin should deal with links to articles, components, and categories so that the links are readable.
    But why does the SEF plugin convert the addresses of styles, scripts, and images?
avatar korenevskiy korenevskiy - change - 18 Dec 2020
The description was changed
avatar korenevskiy korenevskiy - edited - 18 Dec 2020
avatar Fedik
Fedik - comment - 19 Dec 2020

First of all, stop crying, and get hold of yourself. It not end of the world.
And start use Joomla API to add JS/CSS, and to get a correct path to your AJAX (tip: with JUri), then you will not have such errors.

Second, existing <base> behavior in Joomla 4, same as in Joomla 3.
If it is incorrect and has to be changed then it should be discussed separately.

avatar korenevskiy
korenevskiy - comment - 19 Dec 2020

First of all, stop crying, and get hold of yourself. It not end of the world.
And start use Joomla API to add JS/CSS, and to get a correct path to your AJAX (tip: with JUri), then you will not have such errors.

Second, existing <base> behavior in Joomla 4, same as in Joomla 3.
If it is incorrect and has to be changed then it should be discussed separately.

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,.
1.what are the reasons for using <base> in the wrong format, and what is the point of it today?
2. it should be corrected.
3. I do not pay, And you wrote me a message here, but did not say anything about the case.
Do you personally know how to find out the site address using JS located in a subfolder? Write to the case.

avatar Fedik
Fedik - comment - 19 Dec 2020

And what api should I use to get the address in JS?
... how to find out the site address using JS ...

easy:

JHtml::_('behavior.core');
var sysPaths = Joomla.getOptions('system.paths'),
  basPath = sysPaths.base + '/';

what are the reasons for using in the wrong format

As I said, it need to be discussed, I have no idea.
Try open a topic https://github.com/joomla/joomla-cms/discussions

avatar korenevskiy
korenevskiy - comment - 20 Dec 2020

I checked your code in different sites and servers Joomla.getOptions('system.paths'):
http://localhost/joomla/ -> {root: "/joomla", base: "/joomla"}
http://joomla/ -> {root: "", base: ""}
MySites with Joomla:
https://explorer-office.ru/download/joomla/product/view/1/1 -> {root: "", base: ""}
https://orelmusizo.ru/vystavki -> {root: "", base: ""}
https://www.mugyarn.ru/ -> {root: "", base: ""}
MySite with Joomla4
https://sites.explorer-office.ru/home/podpunkt3 -> {root: "", rootFull: "https://sites.explorer-office.ru/", base: "", baseFull: "https://sites.explorer-office.ru/"}

As I said, it need to be discussed, I have no idea.
Try open a topic https://github.com/joomla/joomla-cms/discussions
excuse me, i did not know that there is such a section for discussions. I haven't seen him anywhere. So I didn't expect to see him here. thank you for pointing out the existence of such a discussion section. Excuse me for being harmful. i thought that all problems are discussed only in the issue.

i checked your script, it is not functional.
But actually I made a mistake the <base> tag works in many installations.
I just don't understand why the <base> tag doesn't work only in one site, on the site where I created my component. Of course, I thought that such an error is global.
https://orelmusizo.ru/informatsiya/otzyvy
On this site, I turned off all plugins in turn, but the <base> tag still shows a copy of the site link. i can't figure out what's going on.
Strange everything is very strange.

avatar rdeutz rdeutz - change - 20 Dec 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-12-20 13:57:55
Closed_By rdeutz
avatar rdeutz rdeutz - close - 20 Dec 2020

Add a Comment

Login with GitHub to post a comment