I have one problem. I have three files header.php
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/resources/style.css">
<title>System stypendialny</title>
</head>
<body>
index.php
<div id="wrapper">
<div id="logo">
<h1>Nazwa strony</h1>
<p>slogan</p>
</div>
</div>
<div id="header">
<div id="title_head">Lorem ipsum</div>
</div>
<div id="container">
<div id="content">
<h2>Witaj na naszej stronie</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget tortor vitae purus bibendum ornare at sit amet mauris. Aenean adipiscing velit a tellus sodales quis commodo metus congue. Cras ac erat eget urna faucibus pellentesque sit amet eget metus. Vestibulum ac hendrerit sapien. Vivamus consectetur dui at nisi dictum tincidunt ac ut purus. Praesent id ornare velit. Morbi fringilla, justo nec tincidunt hendrerit, mi ante ornare magna, id sodales dolor erat quis ante. Sed vel adipiscing nisl. Etiam lectus turpis, fermentum quis vehicula at, elementum vitae nibh. Duis at leo eu purus aliquet rutrum. Phasellus posuere, ante condimentum sagittis venenatis, sem tellus venenatis arcu, ac iaculis quam lorem at urna.
</p>
</div>
<div id="sidebar">
<h2>O nas</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget tortor vitae purus bibendum ornare at sit amet mauris. Aenean adipiscing velit a tellus sodales quis commodo metus congue. Cras ac erat eget urna faucibus pellentesque sit amet eget metus.
</p>
<h2>Polecam</h2>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>
</div>
</div>
<div id="footer">
<p>© Wszelkie prawa zastrzeżone. <br /> Projekt: <a href="http://www.templatki.net">Darmowe Szablony Stron</a></p>
</div>
</div>
</body>
</html>
and view.php where I include header.php to another files
<?php
class View
{
function __construct()
{
}
public function Render()
{
require_once 'views/Header.php';
$file = 'views/' . $this->controller . '/' . $this->page . '.php';
if (file_exists($file))
require_once $file;
else {
$this->message = "Nie znaleziono pliku";
require_once 'views/Error.php';
}
require_once 'views/Footer.php';
}
}
The problem is that the file css doesn't include and I don't know why. Do you have any suggestions? A tried everything but didn't work.
The issue is likely path related but you can be certain by inspecting the page with developer tools (control + shift + i
in most browsers).
Depending on where your view.php
file is living, you'll need to adjust the link
to the CSS
file. Right now you just have /resources/style.css
but everything else is included using the preface views/filename
. If you supply your directory structure we might be able to give a solid solution but this should get you going in the correct direction as well.
UPDATE:
It seems you need to move up one directory using ../
since the style sheet does live in the view
directory. Try changing the link to:
<link rel="stylesheet" type="text/css" href="../resources/style.css">