Web development newbie here. My site is becoming large enough that recently took a few steps to help manage it including:
- Using a separate header.php; footer.php; and navigation.php file with an includes tag.
- Filed additional pages under root/pages. Below is a snapshot of my current folders:
- root
- pages
- assets
- images
- js
- php
My issue now that I have nested additional pages (other than index.html) in the pages folder. When coding these files, the link/include files are causing issues, because of the relative/absolute file reference. Through some research I was able to use this php code which seems to work for the header, footer, and navigation menu:
<?php
set_include_path( implode( PATH_SEPARATOR, array(
$_SERVER['DOCUMENT_ROOT'],
get_include_path()
) ) );
include 'root/assets/header.php';
?>
The issue I have now is the css link no longer works either:
<link rel="stylesheet" href="css/style-services.css">
I have tried doing this with no luck:
<?php
set_include_path( implode( PATH_SEPARATOR, array(
$_SERVER['DOCUMENT_ROOT'],
get_include_path()
) ) );
include 'root/css/style-services.css';
?>
How do I insure the referenced css also gets included when using a file structure and php include functions?