Solved

Please explain this CSS

Posted on 2016-09-05
5
106 Views
Last Modified: 2016-09-06
Hello!

I've noticed this code when I viewed page source:

<link rel="stylesheet" href="css:style.css" />

Open in new window


It doesn't make sense to me, 'cos it's NOT a valid URL to an external CSS file. The developer said something like this:
"It is reserved for the file > css/custom.css"

They also said:

The missing URL for the custom.css depends on the php code to include the css file.
If there is no css file to load, the code is blank"
>> layouts/theme.config.php

$this->addFile('css', 'css:custom.css');

Open in new window


I found this line of PHP code in template.config.php

$this['asset']->addFile('css', 'css:custom.css');

Open in new window

0
Comment
Question by:Member_2_7970041
5 Comments
 
LVL 1

Expert Comment

by:Stefan Hoffmann
ID: 41785603
Well at least it does not look harmful. It looks odd to me, too, but I do not use Joomla. Maybe this is how they do things.

Anyway - in your place - I'd look at the result. You know, browse to the page and use "show source code" in the browser to check what the html says it does.
The browser (or http://www.telerik.com/fiddler) will probably be able to tell you also, if you produce a HTTP 404 this way. And although we might understand or not understand the PHP - as long as the page itself runs...
1
 
LVL 55

Expert Comment

by:Julian Hansen
ID: 41785619
It looks odd to me, too, but I do not use Joomla. Maybe this is how they do things.
Except the author said
I've noticed this code when I viewed page source:
So this is after Joomla has finished in the process - this is the final output sent to the browser - and it is not valid.
One outside chance is there is some javascript that runs and modifies that link after page load but not sure I see the advantage.
1
 
LVL 1

Expert Comment

by:Stefan Hoffmann
ID: 41785740
I have overlooked that. Sorry. Julian is right.
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41785878
I'm almost certain this is an error.  This:
addFile('css', 'css:custom.css');

...should probably be written more like this (note directory separator):
addFile('css', 'css/custom.css');

You may be able to use Chrome Dev Tools to see what the browser is doing with the <link> tag.  My guess is that it would be getting a 404.
0
 

Author Comment

by:Member_2_7970041
ID: 41786684
Thanks all of you for your replies!

At least, it's not harmful for the site (if I understood this part right). It's strange that serious commercial developers from Germany can't understand the wrong code. And when I brought it to their attention, they gave me that explanation, written above. Maybe they know something we don't.
Anyhow, if I have nothing to worry about, then I guess I could close this question.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question