Advantages of nesting webpage in another webpage?

Pretty much as explained by the title: I am building different pages for a website. All of the pages will have a menu bar on the left at fixed position.

There are two ways that I can approach this:

  1. Create a Insert menubar function to insert the menu bar for every pages

  2. Create a home.php with the menu bar, and nest other pages in an iframe

I have already done things using the first method and now the requirement is for me to implement the second approach.

Is the word “responsive” part of the requirement? If yes, then forget the iframe approach.

1 Like

Responsive should be part of the requirements, as we would like to be able to access the website across devices.

So nesting is advised against?

Definitely.

You need the different parts of the page to be able to rearrange themselves depending on the space available in the viewport.

Common sections can be incorporated using include statements in whatever server side language you are using so that they only need to be coded once.

2 Likes

Sounds like you are talking about framesets which are basically evil.

Using includes as felgall suggests is the way to keep consistent elements such as navigations headers and footers in one place but included on all pages.

1 Like

Thanks guys, I need to think of a way to break it to the client

Consider telling him that using framesets

  • might negatively affect SEO
  • could cause Accessibility problems
  • will result in a less than ideal Mobile experience

Thanks!

Looks like you are already using php files for your pages, so php includes seems like the natural choice for this. Eg:-

<?php include $_SERVER["DOCUMENT_ROOT"] . "/includes/menu.php"; ?>

Indeed

includes et al were one of the things I first took advantage of years ago.
And I haven’t stopped since. An extremely big time and effort saver.

Includes are what first drew me to php. I was sick of copying and pasting a menu into multiple html files every time I added or removed a page from the site.
You may start out only using the odd include here and there, but it can lead to you trying harder stuff. :worried:

I had already been using includes in my pages for a long time before I started using PHP. You don’t need PHP if all you want is includes. You can use Server Side Includes without using any server side language if all you want are includes.

Of course a server side language like PHP provides for lots of other things and not just includes.

I had used SSI to run CGI (Perl) before I found PHP (3)

But I never thought of doing it for page elements before that.

Initially all I wanted was includes, but I never found a way to do that without php. But I don’t regret turning to php at all, as I soon saw the potential of what else I could do with it. Now I couldn’t be without it.

For just includes you use a .shtml extension and then write the include as:

<!--#include virtual="../header.txt" -->
1 Like

Thanks. That’s useful to know for sites that do not require full-on php scripting.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.