What is the relative path? Topic is solved

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
Nickinamillion
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Mon Feb 29, 2016 10:31 am

What is the relative path?

Post by Nickinamillion » Sun Apr 11, 2021 7:16 pm

I have been trying to get the path right in my style sheet, I eventually manage to figure out the absolute version.
I think this is pretty basic but it has confounded me. The question is what is the relative path in the style sheet to the picture?
Below is the code in the style sheet:

Code: Select all

body {
    background-color: #359b37;
    background-repeat: repeat-x;
    background-image: url(http://localhost/Joomla.site/images/background/WBCinGrassRepeat.jpg);
}
This is an example of the path to my picture:
C:\xampp\htdocs\MySite\images\background\MyPicture.jpg
This is an example the path to my style sheet:
C:\xampp\htdocs\MySite\templates\MyTemplate\css\user.css
What should the reletive path in the styles sheet be that will load the MyPicture.jpg?
Nick

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 27699
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: What is the relative path?

Post by Per Yngve Berg » Sun Apr 11, 2021 7:38 pm

The relative path is to the css folder where the css file is located.

Image files that belong to the template should be located in the template.

'../images/background/WBCinGrassRepeat.jpg' will loaded from image in the template. The double dot means parents folder.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 39806
Joined: Sat Apr 05, 2008 9:58 pm

Re: What is the relative path?

Post by Webdongle » Mon Apr 12, 2021 2:03 am

Will ../ take it back to C: ???

Perhaps on localhost
./././images
Would be better?
1st ./ back to the Template
2nd ./ back to the templates folder
3rd ./ back to the site root
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

Nickinamillion
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Mon Feb 29, 2016 10:31 am

Re: What is the relative path?

Post by Nickinamillion » Mon Apr 12, 2021 9:37 am

Thank you both. Unfortunately, neither of your solutions worked, I can not understand why.
I have set this scenario up on my live test site at:
http://www.basictest.mrbumble.biz/
It would nice to find out what the solution is?
N

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 39806
Joined: Sat Apr 05, 2008 9:58 pm

Re: What is the relative path?

Post by Webdongle » Mon Apr 12, 2021 1:53 pm

Nickinamillion wrote:
Mon Apr 12, 2021 9:37 am
...
It would nice to find out what the solution is?
...
Use the full path on localhost then Per Yngve Berg's when you move it to a remote Host?
or try on localhost
.\.\.\images
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 27699
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: What is the relative path?

Post by Per Yngve Berg » Mon Apr 12, 2021 2:01 pm

A single dot means current directory and does not take you back anywhere. Two dots is parent.

../../../images

/images will also do when Joomla is installed at the web root.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 39806
Joined: Sat Apr 05, 2008 9:58 pm

Re: What is the relative path?

Post by Webdongle » Mon Apr 12, 2021 3:51 pm

my bad
../../../images
should work

Starting to worry about my memory :'(
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

Nickinamillion
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Mon Feb 29, 2016 10:31 am

Re: What is the relative path?

Post by Nickinamillion » Tue Apr 13, 2021 7:29 pm

Thank you both again. I have found that the primary problem is not the path but the cache not clearing. I see in dev tools that the path in the user.css file is not updating and obstinately holds on to an old file name. I have been clearing the cache on the browser, what's that about? why is it not clearing? how do I get it to work properly?
I am using firefox developer, XAMPP, Windows 10 and now Joomla 3.9.26 (teetering on 4).

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 10163
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: What is the relative path?

Post by sozzled » Tue Apr 13, 2021 7:44 pm

Nickinamillion wrote:
Tue Apr 13, 2021 7:29 pm
I have found that the primary problem is not the path but the cache ...
OK. So clear the cache. What's so hard about that? If the primary problem is about caching, disable caching while you're designing and building your website within your PC-hosted server environment and re-enable caching when you've finished your development work.

"Teetering on J! 4 ..." :laugh: :laugh: :laugh: I fell of the chair laughing.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

Nickinamillion
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Mon Feb 29, 2016 10:31 am

Re: What is the relative path?

Post by Nickinamillion » Wed Apr 14, 2021 9:45 am

Hi sozzled, I am glad to hear from you, I am glad you are OK. Thank you all for your help. I have now found the problem, which was a tangle of my own construction. However, I have learned many things, "learned by my mistakes", if that were true I would be the wisest man ever.
So, what was the problem? The incorrect path and filename were in a user.css file that was in a template that was not the default template that I thought I was using. It was another one that was not ticked on the template>style page. So to correct that I went to template>styles>menu assignment tab and toggle selected all options. I found this out by improved scrutiny of dev tools, which also showed that my cache wasn't clearing.
The original question about paths is that:
url(../../../images/repeats/WBCinGrassRepeat.jpg) works as a relative path,
url(https://localhost/mrbumble.local/images ... Repeat.jpg) works as an absolute one.
Thank you all for your help and interest in my endevers. N


Post Reply

Return to “General Questions/New to Joomla! 3.x”