Jump to content
Larry Ullman's Book Forums

Recommended Posts

Just noticed a problem and not sure what I am doing wrong.

 

I think I have the <title><php echo $page_title; ?></title> statement in the right place but when I test the page through the local server i get

 

<php echo $page_title; ?>

 

Attached the code from the header and the home page. If I take the php statements out and put a name in the title tags it returns 'local host'

This is the header page code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><php echo $page_title; ?></title>

This is the home page code
<?php
$page_title = 'Home';
include ('header.html');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

Link to comment
Share on other sites

Well, you can specify an absolute path or a relative path.

If you're using XAMPP or the like, then an absolute path would be one that starts with the drive letter (like C:).

Generally, the relative path is shorter than the absolute path because you write a path to the file relative to the file including the other one.

See Larry's book for details.

Link to comment
Share on other sites

Just noticed that when I include the header on a page that's not in a folder all I need is include ('includes/header.html');

 

If I include a page thats actually in a folder when I test the page it says it cant find the includes path, so on those pages I have added the path i.e

include ('..//includes/header.html'); then it works fine and displays the header OK in the browser.

 

Is this normal or have I done something wrong again?

 

I have pages that display from the site and then I have folders like Jobseekers folder with all the pages relating to jobseekers contained in the folder. I've done this just to keep the directory tidy.

Link to comment
Share on other sites

I'm not sure what you mean by a page being in a folder vs. not being in a folder.

Any file that can be recognized by an OS (or any file system, for that matter) is in a folder one way or another.

As such, I can't understand the distinction you're making there.

 

In general, if the include file is in a subfolder of the file doing the including, then a relative path like 'includes/header.html' is sufficient.

If both files are in the same folder, then something like 'header.html' is fine.

If the include file is above the other file in the folder structure, then you'll have to start a relative path with something like '../'.

Link to comment
Share on other sites

Thats what it is hartley. Some of the pages are in subfolders. I have added an extra menue to the nav bar and it updates all the pages OK regardless if they are in the main site folder or a subfolder. I have to copy over the images into the subfolders image folder for some reason but anyway it works and everything updates all the changes made to the header. If i go into one of the pages say about the address is just www.trsb.co.uk/about.php but if I go into a page thats in a subfolder the address is www.trsb.co.uk/contact_folder/contact.php Can you see the subfolder "contact_folder"/contact.php. Its like putting the header and footer into an "Includes" folder. It keeps the site structure tidy.

Link to comment
Share on other sites

Larry also recommends putting all the include files (with the exception of the DB connection script) in a subfolder, so that's a good idea. With that said, for a site like yours, there probably won't be much need to put any of the main pages in subfolders.

 

Ultimately, how you organize all the files is your choice, but I think that keeping all the main pages in the top Web folder helps keep the URLs for your site cleaner an easier to remember.

 

Also, the images had to be moved because the scripts referencing them were moved. All resources that are included in a file using relative paths must always remain relative to that file in the same manner.

Link to comment
Share on other sites

I'm going to finish building the site using subfolders because it's easier for me to find things (I'm learning as I go) instead of there being just one long list of pages. You are right though if I change any of the images in the future or someone suggests a new nifty nav bar then I would have to go through all the subfolders and change things, so when I finish it I will take the pages out of subfolders so it's easier to update in the future.

 

Ive finished the structure and created all the forms, so now for the tricky part of custom codeing them so they display the data right and put things into and retreive from the database.

 

I may be on here rather often asking for help and some of the things I ask will probally seem obvious to the more experianced lads so, I will appologise in advance if i become a nusence. I am determined to get this site built i started to learn this because I got fed up of people who said they could build us a site, got half way through it and then vanished of the face of the earth and left us high and dry but not before they got paid for what they had already done. So I bought Lary's book and away I went.

Link to comment
Share on other sites

 Share

×
×
  • Create New...