Is my thinking straight? (php include)

For a given page in the site, once built, the only thing that will change is the menu column. But that will change every week as new pages are added to the site. I’m considering converting each html page into a php that differs from what I have now only by replacing the imbedded unordered menu column with a php include file of that unordered list. (So that, when I add a new page to the site, the only change I need to make is to the include file, not to every page.)

An alternative, I’m aware, is to create abstract classes and inherit into the children per OOP protocol. But that seems to me a bit of overkill.

And, of course, I could leave things the way they are and make the trivial change to each page’s menu as I add new pages. Since the site is unlikely to exceed sixty or so pages, such an option is not all that onerous.

Oh…
And are there any SEO implications of switching from .htm to .php extentions as long as I don’t start sessions?

Regards,

grNadpa

Yes, an include sounds reasonable to me. You definitely don’t need to make it more complicated utilizing principles of OOP for something that is fairly static.

Then as it changes, just update the file the includes refer to and you are good to go. As far as SEO, if your site is pre-existing, yes, you’ll take an SEO hit unless you setup redirects for your existing htm file to now redirect to the php file using htaccess indicating a 301 (permanent redirect).

The other thing you could look at, 1) enable htm pages to parse PHP, thus removing the need to change the file extension, and 2) SSI includes.

Other than the changing the extension, you shouldn’t see any SEO impact (sessions by themselves do not cause SEO implications).

Not an issue as this site is still “a pigment of my inebriation”. And, in any case, it looks as if my content provider is going to bail.

I didn’t know I could enable htm pages to parse PHP. I’ll Google that as well as SSI includes. Thank you

Sorry, I should have mentioned this up front too, but you will take a “slight” performance hit enabling htm pages to parse PHP. As it will have to run the htm pages through the PHP parser regardless if there is any PHP to be processed. I don’t think it will be noticeable to you, for what you plan to use it for.

Off Topic:

I’d never heard that before… good one :smiley:

Found a great writeup for SSI Includes at http://www.htmlgoodies.com/beyond/webmaster/article.php/3473341/SSI-The-Include-Command.htm

But my server requires that I use extension .shtml.

So, comes the question, since I have to change the extension in both cases, is there any reason to use a php include over an SSI or vice versa?

Do you ever see the need to make things a bit more complicated than including “this file”? Such as, if you are an admin, also show this link in the navigation? If so, you’d want to use PHP, if not, you can get away with SSI.

Now I have path problems. The file I want to include is menu.php and resides in the root directory along with my (site’s landing page) index.php. All the other pages are also named index.php but in their own folder. For example do-the-laundry/index.php.

When I code

include 'menu.php';

It works in the the landing page index.php but not in the do-the-laundry index.php
When I code

include_once dirname(__DIR__) . '/menu.php';

it works in the do-the-laundry index.php but not in the landing page
When I code

include_once dirname(__FILE__) . '/menu.php';

it does not work in either place.

Am I stuck to have to treat the landing page differently from the other pages simply to handle the include?

Generally, I’d just modify the include statement for the files in each folder to:

include '../menu.php';

You may need to use …/…/ if you are two folders deep (you get the idea).

So if I understand, the answer to my question is “Yes, I will have to code the include in my landing page (in the root folder) differently than the include in folders subordinate to the root folder.”

You don’t have to, as there are ways to programmatically resolve it, but for a simple site, I don’t see the point in doing so. You simply want to include a file in each index.php page you have throughout your structure, just update the include path.

Granted, you can always hard-code the full path, but that makes deployment annoying (ie: /home/user/public_html/menu.php)