repeated chunks of HTML on each page...

User 1976497 Photo


Registered User
10 posts

I want the same banner and menu bar on each page of my website. At present, I copy and paste the code from one page to another. This is very tedious and irritating when a change is required.

What mechanism is available to insert common chuncks of HTML code?
User 187934 Photo


Senior Advisor
20,196 posts

Use a PHP include.
<?php include('mybannername.html');?>

The only thing on the mybannername.html page would be your banner code.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1976497 Photo


Registered User
10 posts

Eric -- Thank you for your reply. However, it does not work for me. It would be wonderful if this simple PHP include statement could insert the header, footer code.

I have double-checked all aspects of the script and the code snippet. Might the problem be that I cannot see a ".htaccess" file up on the FTP Server root?

I must be doing something wrong.
User 187934 Photo


Senior Advisor
20,196 posts

Add this line to your .htaccess
AddType application/x-httpd-php .html
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 1976497 Photo


Registered User
10 posts

Eric -- After such a simple answer from you, I am now bombarding you with follow-up nits. I do apologise for my stumbling thickness.

I can't see or find the .htaccess file -- neither in the folder list in the local directory tab nor under the FTP tab. I have enabled "show hidden and system files"
User 187934 Photo


Senior Advisor
20,196 posts

Try making one. Open notepad and paste the code into the page and save it as .htaccess
Upload this to the root of your site.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 122279 Photo


Senior Advisor
14,465 posts
Online Now

... And if you have problems uploading it (I have seen that some people have), then save it as htaccess.txt and upload. When it is on the server, you can rename it to .htaccess.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 1948478 Photo


Senior Advisor
1,850 posts

...and if you continue having problems with the .htaccess file (i.e. having your server parse php as html), just do things the old-fashioned way and change the file extension from .html to .php for all files where you use the php includes.
Also change 'mybannername.html' to 'mybannername.php'...

Ref.: http://www.w3schools.com/php/php_includes.asp
User 122279 Photo


Senior Advisor
14,465 posts
Online Now

... Or use object includes. You don't have to change any file names for that.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 1976497 Photo


Registered User
10 posts

I'm fixxed and happy.
Eric, Inger, Per -- thank you all for the swift help. This is the best and most useful help that I've had on any user forum. I know that it is only a small thing but it is fundamental to the contruction of a family of web pages. I think that the techniques which you showed me should feature more obvoiusly in CoffeeCup tutorials -- "How to manage common sections of code in multiple pages"

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.