Jump to content

Passing CSS to 'include'ed pages..


FireWhizzle

Recommended Posts

After crawling around this site and a few others I am resorting to making a post asking a question (AHHH!).

 

Situation:

I have php file A, which includes php file B.

php file A loads a *.css file in the header and formatting is correctly applied.

php file B however does not inherit the formatting from the *.css file applied to php file A.

 

What I've derived:

If I write the link to the *.css file in B I cannot get it to format correctly.

In the case stated one line above, if I go to php file B in a browser directly, not by including it in php file A, the formatting of course works correctly.

 

Question:

Is this an issue with using the include function or must it be an error in php file B?

 

Thanks in advance!

Link to comment
Share on other sites

Here posted are links to php file A and php file B, as well as active code snippets of question.

 

Link to php file A including php file B:

http://www.actorchrisadams.com/index.php?page=video

 

index.php code snippet:

  <?php
  $page = $_GET['page'];

   if($page == 'headshots') {
    include 'headshots.php';
   }
   elseif($page == 'video') {
    include 'video.php';
   }
   elseif($page == 'voiceover') {
    include 'voiceover.php';
   }
   elseif($page == 'resume') {
    include 'resume.php';
   }
   elseif($page == 'contact') {
    include 'contact.php';
   }
   else {
    include 'uc.html';
   }
  ?>

 

 

Link to php file B standalone:

http://www.actorchrisadams.com/video.php

 

video.php code:

<HTML>
<HEAD>
  <LINK HREF="main.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY>
  Test 123
</BODY>
</HTML>

 

 

Link to comment
Share on other sites

it's because you're opening/closing HTML tags several times in the two files. is there a reason why they're standalone HTML pages, and yet one is being included within the other?

 

You have most likely just solved my dilemma. I am somewhat inexperienced with nested pages, as I have only built one site previously and it was years ago. I will give this a try and update for reference to others.

 

I changed video.php aka php file B to this:

Test 123

 

The links up top are updated for reference. The font formatting still isn't applying correctly. The correct formatting is like that of the bottom copyright line. Thoughts?

Link to comment
Share on other sites

it's because you're opening/closing HTML tags several times in the two files. is there a reason why they're standalone HTML pages, and yet one is being included within the other?

 

You have most likely just solved my dilemma. I am somewhat inexperienced with nested pages, as I have only built one site previously and it was years ago. I will give this a try and update for reference to others.

 

with nested pages (or included sections), you will usually want to have the "container" file hold all the parental HTML data such as the html, head, and body tags. the included files themselves should only contain data pertaining to the physical section of the site they are meant to represent (if that makes sense).

Link to comment
Share on other sites

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.