Anyone know PHP/HTML?

Slippertalk Orchid Forum

Help Support Slippertalk Orchid Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

silence882

Horse whisperer
Supporting Member
Joined
Jun 7, 2006
Messages
1,085
Reaction score
389
Location
Maryland
Hello all,

I have recently added a CSS menu to slipperorchids.info and am running into a bit of a hurdle. I have to paste the HTML for the list the menu uses into each page on the site, which is around 100 atm. So every time I want to make a change to the menu, I have to paste new code to all 100 pages.

Is there any way to put the menu into a separate file and then place a single statement on each page that automatically imports the menu?

From googling, I thought this was possible using PHP. So I created a file titled menu.php with the list HTML in it and used the following statement to try to bring it in:
<?php include 'http://slipperorchids.info/menu.php'; ?>

However, this doesn't work and I believe it is because PHP can't be directly placed in an HTML document.

I know very little of PHP and CSS, so if anyone can help I would appreciate it.

Thanks,
--Stephen
 
If you want to PM me, I may be able to help further.

If you're not using a CMS or other framework, you probably want to consider migrating to one at some point in the future.

But assuming all your pages are basic PHP files, then you should be able to use the include statement, but you need to provide it with a directory or file path (i.e. not a URL). Depending on your setup, you may be able to use relative paths (i.e. if everything is located at /var/www/httpdocs/), you might be able to do use include "menu.php". Otherwise, if you've got a nested structure with lots of directories, you'd want to use the absolute path, such as include "/var/www/httpdocs/menu.php". Unfortunately, the /var/www/httpdocs/ path is just a guess. That's a very commonly used directory structure, but it is by no means universal.

If all your pages are raw HTML, then you'd need to convert them over to PHP files so that your server (presumably using Apache) will know to interpret the PHP code before rendering the pages.

Another option ... whether all your pages are HTML or PHP, you might be able to use some Javascript wizardry to inject the menu.
 
Thanks for the tips!

I've considered using a CMS, I just haven't had the time/motivation to figure one out.

All the pages are basic HTML, so I'd have to do more research to convert everything to PHP.

I will comb the internet to see if maybe I can use JS to do this.

--Stephen
 

Latest posts

Back
Top