Log in

View Full Version : Save CSS in files


Alphawolf83
10-10-2007, 03:33 PM
Hey there,

the option to save CSS into files on the server outputs the following link to the CSS file:
<link rel="stylesheet" type="text/css" href="clientscript/vbulletin_css/vbulletin_dfgfdgfdgfdgdfgr556464.css" />

However, the structure of our forum is like following:
./ = (root) Portal
./forum/ = Forum

Now, as long as I move inside the /forum/ the above link works fine, since the clientscript/vbulletin_css/ folder is located inside the /forum/ folder. :)

However, when I navigate to our Portal (which is completely written by ourselves, no hacks etc.), the link to the css files doesnt work anymore, understandably. The link then should looks like this
<link rel="stylesheet" type="text/css" href="forum/clientscript/vbulletin_css/vbulletin_dfgfdgfdgfdgdfgr556464.css" />
to work properly.

So now, how do I change the automatically generated link to the CSS file when I am outside the forum or in general? Hope, anything was understandable (I'm german ;)).

Greetz

Analogpoint
10-10-2007, 04:59 PM
There are *lots* of ways to deal with something like this. One way would be mod vB to output an absolute URL for that link, then it would work everywhere. I'd probably do this. Another way, would be in your portal code, buffer the output to the browser then fix the link

// at the beginning
ob_start();

// at the end
$allcontent = ob_get_clean();
$allcontent = str_replace('href="clientscript/vbulletin_css/', 'href="forum/clientscript/vbulletin_css/', $allcontent);
echo $allcontent;

And then there are lots of other ways too :)

Alphawolf83
10-10-2007, 07:55 PM
Unfortunately, that didnt work for any reason, but a fellow administrator had a working solution. :)

- Create Plugin (Hook: global_complete):
$output = preg_replace('/<link ([^>]*)href="(?!http|\/)([^"]+)"/', '<link $1href="'.$vbulletin->options[bburl].'/$2"', $output);


Works just like a charm. Thanks spli. :p

Dismounted
10-11-2007, 10:11 AM
Or you could just put this in your headinclude template.
<base href="$vboptions[bburl]" />

Analogpoint
10-11-2007, 01:53 PM
Or you could just put this in your headinclude template.
<base href="$vboptions[bburl]" />

Which would break any other relative links you have on the page. Of course if there are no other relative links, that's a perfect solution. (And one that didn't cross my mind.) :)