[kdewebdev-site] Problem with the site layout

Alexander Hans alexander.hans at stud.tu-ilmenau.de
Tue Mar 1 14:32:04 EST 2005


Hi,

I don't  know how this looks exactly, haven't had a look at the code, I
don't know if I even have access. But here are my comments on what I think
what might cause problems.

>  I'm trying to create a kallery homepage that follows the current
> layout, but have some problems. applib.php contains rules that should
> grab the common files (CSS and PHP files) from the main kdewebdev site:
> if ($_SERVER["HTTP_HOST"] == "kallery.kdewebdev.org") {
>   $_libpath = "/home/kdewebdev/public_html/include/";
>   $_imgmain = "/home/kdewebdev/public_html/images/";
>   $_css = "/home/kdewebdev/public_html/css/";
>   $_mainsite = "http://kdewebdev.org/";
[...]
> }
> include_once ($_libpath."left.inc.php");

You have two different kinds of files, one is files that are directly
accessed by the browser, the other is files that are included by PHP to
create one documenent.

It doesn't make much sense to have filesystem paths to images and css
files. You probably don't want to access those files from within your PHP,
but want to create links to it so the browser knows where to find CSS
files and images. That's why it did work when changing it to the external
address.



> With the above code, nothing is found, the layout is totally broken. If
> I use
>   $_css = "http://kdewebdev.org/css/";
> The CSS file is found, but the pictures used in the CSS file are not.
> Example from there:
>   background-image:url("../images/page/bg_line_.gif");
> I suppose if I change the url to
>  background-image:url("http://kdewebdev.org/images/page/bg_line_.gif");
> it will work.

You are right, that way it would work. I remember I had that problem
before, strange behaviour when refering image files from CSS files. You
could try to change to the following:

background-image:url("../../images/page/bg_line_.gif");

This is what did it for me, however I don't know why that is. Logically I
would expect you'd have to specify a path relative to the CSS file's
location, so just one "../" should do to get to the root.


>  But this will not solve the problem with the common PHP files. How can
> we do that
> include_once ($_libpath."left.inc.php");
> always includes the left.inc.php from the main kdewebdev?

You can do that by setting $_libpath to the same directory (filesystem
path) in each PHP file and placing left.inc.php in that directory. A
better approach would be to create a file named globals.php, defining
everything that's needed on all pages in there, and including only that
file as first statement in each PHP file that's accessed to render a page.

Generally I don't like that way of including content, though. You might
want to consider using a really simple template system, that way you
wouldn't add much complexity, nevertheless it would give a nice separation
of PHP and HTML, thus increasing maintainability. I've created one some
time ago and used it for my own projects since, you can have it if you
want to.

I wanted to reply to that initial email asking for developers for the
website, didn't get around to do it though. But I'm available for doing
some PHP development if you need help. I have quite some experience with
LAMP-based websites and recently switched to PHP5.


Best regards,

Alex

-- 
PGP Public Key: http://www.tu-ilmenau.de/~alha-in/ahans.asc
Fingerprint: E110 4CA3 288A 93F3 5237  E904 A85B 4B18 CFDC 63E3



More information about the kdewebdev-site mailing list