Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

XHTML code duplication/template

Featured Replies

Hi,

 

I'm new so like I've posted before please persevere with me on topics you may find tediously simple...

 

Im looking for a way in which content can be dupilcated throughout a website in the same way formatting in a website is all controlled by one or two css files. Allow me to elaborate...

 

If, for example, I begin putting together a small website of say 6 pages in HTML I will no doubt want a menu system to navigiate it. The navigation may go as follows along the top of each page;

 

home, gallery, sales, projects, contact, about,

 

how do i change the menu system on one page so that all pages display the changes;

 

home, gallery, SERVICES, projects, contact, about... I don't want to have to go into each of my 6 pages and change the code for each menu individually. I know this could be done with dreamweaver mx editable/non editable regions but is there a less fiddly way? Footer content on each page needs to stay exactly the same throughout on most sites also so the same would apply to this. If you want to change the content in your footer do you have to alter the html code for each page?

 

Please help

Is PHP an option? I can quite easily write you something to load the the menu from 1 file.

 

Sam

if PHP isn't an option then you could just do a FIND/REPLACE in dreamweaver and set it to Entire Local Site.

 

Be careful with this though, you don't want to overwrite a load of stuff by mistake!

 

PHP is the best option though :)

on mentioning dreamweaver - it does have a template system itself if that is what you are using... .dwt files i think .. you make a basic template for the site and choose what is editable in separate html files.

  • Author

thanks ever so much for the quick replies guys. i wouldnt even have thought about PHP. Ive only been learning HTML&CSS the past 18 months or so and before that it was "drag and drop" in dreamweaver whilst skimming the surface studying for my business degree. At the momment im only putting togeter small sites > 8 pages so repeating/changing code wont get too frustating but the php solution sounds the best easy... when ive developed my html/css to what id regard a satisfactory level, php will be the next step. I was looking for a similar idea to css files and how they cascade style and formatting throughout a site from just one file. thats a great idea. what methods do u guys actually do though in your own designs??

 

dreamweaver isnt a bad idea - the find replace thing is a simple but maybe uncertain solution that could work still! i found the editable regions templates .dwt files TOO restricting when I first came across them at university.

 

this is all execellent stuff tho, nice one.

The best way Is definately PHP.

 

All you have to do is create a file (menu.php for instance). Put your menu in xhtml into menu.php. Then in your file where you want your menu to show is do this :

 

<?php
//Im presuming menu is in a folder called "template-files".
include_once($_SERVER['DOCUMENT_ROOT']."/template-files/menu.php");
?>

  • Author

The best way Is definately PHP.

 

All you have to do is create a file (menu.php for instance). Put your menu in xhtml into menu.php. Then in your file where you want your menu to show is do this :

 

<?php
//Im presuming menu is in a folder called "template-files".
include_once($_SERVER['DOCUMENT_ROOT']."/template-files/menu.php");
?>

 

Skidz, you've been a big help there thanks for taking time to write that out for me, I'll definately have a play with that before my next project! One question on that though, PHP is a server side language yes, so when I create a domain etc for a future site the server will have to be PHP compatible wont it? My home site that I'm updating at the mo is working from an .ASP server I think.

 

Thanks again!!

  • Author

oh one more thing - how will I format the xhtml code with css if its in a .php file. same as I would normally?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.