Jump to content

Can I Include A Document Within An Included Document? Css/style Sheet In Menu.pp In Webpage.php


Recommended Posts

Each of my webpages use the include file for a menu that I can easily maintain.

I want to include a css.style link with my menu.

Will that work properly or should I echo and print it in the menu.php

 

If anyone has a link to a tutorial on this I would love for you to post it!

I'm not sure what you're asking but I think that the answer is yes.

 

You can just do the ol' fashioned link to stylesheet at the top of each of your files. You can include 100 files within another 100 files if you want.

If you're talking about adding the <link rel=""> tag inside the menu, which is in the body, then know that this is indeed invalid HTML. So while it should not work it may for some, depending upon their browser and its version. (Plus some other conditions outside of your control.) Thus it's a very uncertain method, and it will almost definitely lead to headaches later on.

 

In any case, what I'd do, if I were you, is to add make the header and footer for the pages into their own file(s) as well. Then include the content (or them themselves). That'll ensure that all the pages uses the same structural framework as everything else, and will give you only one location which you need to edit to update this.

 

If you make it so that the content files are included you'll get one entrance file for your site, "index.php", in which you'll have to retrieve and validate the name of the page the visitor wants to see. Then do all of the processing that you need to do for said page, before you write out all of the HTML to the browser. This is by far the most flexible method, even though it requires a bit more work and knowledge up front.

 

The other method, of having separate files for the header and footer means that you only need 2 lines on each content page. Perfect for small & simple sites that don't need to do any real processing of data, but too inflexible to be used for pages that needs to have a high degree of dynamic content. That is, unless change the approach to read the header and footer content to a variable. Which you then, as with the first method, write out with the rest of the HTML content once all of the processing is done.

Problem with that method, is that you'd have to repeat a lot of code across files if you wanted to extend this flexibility to other pages as well.

Edited by Christian F.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.