Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: CSS layout using PHP?

  1. #11
    Join Date
    Jul 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So far as I know, my host does offer support for PHP4 (which they're apparently running as an Apache module(?)) and 5 (by way of a CGIwrap(?)), but I am looking into that just to rule out the possibility that that may be where my problem lies.

    I also did code my test page to add the includes so that it looks something like this: <?php
    include "http://myurl/header.php";
    ?>, but does it matter where on the page (head or body, etc.) it needs to be placed?

    On a related note, since I'm using a navigational setup similar to the one I posted in the first link where it has separate code for CSS which provides the instructions for the navigation using a specific div class and use the ul and li tags for the actual links themselves, how do I cut them out (I am working from a page where I had my original code on and am just doing a cut/paste into new pages for the separate header and footer pages which I'll rename using the PHP extension) if I have to remove the head/body tags since they aren't necessary for this? Also, is there a way to specifically indicate in relation to the page their placement the way that it's possible to do using divs?

  2. #12
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    I also did code my test page to add the includes so that it looks something like this: <?php
    include "http://myurl/header.php";
    ?>, but does it matter where on the page (head or body, etc.) it needs to be placed?
    It needs to be placed where you want the include file to be "dropped-in". so for the header, this really should be on top of everything.. depending if you have the DOCTYPE and all

    I'm using a navigational setup similar to the one I posted in the first link where it has separate code for CSS which provides the instructions for the navigation using a specific div class and use the ul and li tags for the actual links themselves, how do I cut them out (I am working from a page where I had my original code on and am just doing a cut/paste into new pages for the separate header and footer pages which I'll rename using the PHP extension)
    if you have an external style sheet defined in the include script then it will be brought in... and the point of using an external sheet is for this purpose. if you want the styles to only apply to 1 file you should be using embedded style sheets



    Also, is there a way to specifically indicate in relation to the page their placement the way that it's possible to do using divs?
    can you rephrase?

  3. #13
    Join Date
    Jul 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I did move the CSS code regarding things like text/link appearance and the navigational properties to an external style sheet. However, for the links themselves, using the ul and li tags, could those be added to the PHP for the header and then just link the style sheet into the header.PHP file?

    Regardless, I still can't seem to get either my footer (which is just simple text and a text link in bold without an underline) nor my header files to work for me.

    After asking for help regarding the host side of things, I've been given contradictory information with being told all I needed to do was to just place my PHP files into my "regular" web directory and then just add the includes and it supposedly should work because of how Apache was set up (at least, as far as PHP4 is concerned--however, regardless, either I'm doing something wrong with my PHP files, themselves, or there's something on that side that's causing my problems) or how I supposedly shouldn't be using PHP as the extension for the includes, themselves (or else that it supposedly should only be my content pages which have to use the PHP extension)--which seems to not only contradict what I'm reading here, but have read elsewhere online about how to use includes. In the latter situation, I'm more inclined to believe what I've read here.

    Quote:
    Also, is there a way to specifically indicate in relation to the page their placement the way that it's possible to do using divs?
    can you rephrase?
    You actually answered part of my question earlier when I asked about placement. With my original layout, I had things set up so that my footer was a certain percentage up from the bottom of the page and set the height for it. That was part of what I was trying to ask about whether or not this was still possible to do--or would that, as well, still require a stylesheet to accomplish?

    I realize that to some this may all seem rather "brainless" and I admittedly feel like an idiot for having difficulties with this, but quite a bit of this is entirely new to me so again, I do appreciate all the help and insight I'm receiving here.

  4. #14
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello, I had provided the first reply to your post...

    I quickly read through the posts and it seems now you are having problems understanding what the role of your css and your includes play in your case.

    In your case, the includes are only telling the server where to get the next bit of code from. when you type 'include("whateverfile")' you are telling the server to insert everyting from 'whateverfile' . The css serves only as design/layout instructions. so technically the php includes and css do not intereact

    If your webpage looked like this.

    PHP Code:
    index.php
    <head>
    some info
    <code to insert stylesheet.css>
    </head>
    <body>
    some more info
    another line of info
    <? include("header.php"); ?>
    more info
    even more info
    </body>
    and if header.php looked like this
    Code:
    header.php
    menu item 1
    menu item 2
    menu item 3

    this is what you will end up with when the user tries to view the page
    PHP Code:
    <head>
    some info
    <code to insert stylesheet.css>
    </
    head>
    <
    body>
    some more info
    another line of info
    menu item 1
    menu item 2
    menu item 3
    more info
    even more info
    </body

    as you see, header.php was literally pasted right were the include was placed.
    this final code is then sent to the user and te css is applied
    meaning that everyting (header.php and index.php) makes use of the css at once.


    You actually answered part of my question earlier when I asked about placement. With my original layout, I had things set up so that my footer was a certain percentage up from the bottom of the page and set the height for it. That was part of what I was trying to ask about whether or not this was still possible to do--or would that, as well, still require a stylesheet to accomplish?
    with all that being said.... it is still possible for you to position your elements the same way you did before. this is because each included file is affected by the css code at the same time (which after all the 'pasting' has been done).


    In my opinion, if you already had the page looking the way you wanted to before you started to use includes, the only css modifications you may need to make is making it an external stylesheet (which i believe u have done), and making sure each page on your site links to it.

    hopefully i didnt confuse you more, and hopefully i actually answered what you wanted answered
    good luck!

  5. #15
    Join Date
    Jul 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It appears somewhat clearer to me. However, I still can't seem to get things working, but in trying something out today, I found that I may also have a problem with my stylesheet as well. So, first, I'll have to try and fix that and then will try and revisit this again afterwards.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •