Results 1 to 7 of 7

Thread: [solved] xhtml - include

  1. #1

    Thread Starter
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552

    Resolved [solved] xhtml - include

    can i do something like this on xhtml?
    Code:
    <?php include "some.php" ?>
    if so, how? thank you.
    Last edited by brown monkey; Sep 24th, 2004 at 04:41 AM.

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    yes you can. the PHP can still insert XHTML. here's an example:
    PHP Code:
    <?
    include "header.php";
    ?>
    <p>
        More code can go here.
    </p>
    <hr />
    <p>
        This causes noproblem at all. the PHP simply pulls more code from the included files. Just make sure that the code from them is valid. Of course the page will still show if it's not.
    </p>
    Have I helped you? Please Rate my posts.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    PHP just generates text. It's up to you to ensure that this text is well-formed XHTML.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    sorry for the misleading fellas. sorry about my english. what i want to know is actually the include feature of php, if there's any in xhtml. something like modularizing.
    Code:
    <?php include "some.php" ?>
    can i have something like that in xhtml? say, i save a TOC.XHTML and i want to put it in a certain div
    Code:
    <div>
    <!-- include TOC.XHTML -->
    </div>
    hope i clear myself up. thank you.

  5. #5
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    not in XHTML itself, but you can just use PHP again.
    PHP Code:
    <div>
        <? include "div_contents.php"; ?>
    </div>
    Have I helped you? Please Rate my posts.

  6. #6

    Thread Starter
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    ah ok. thank you very much. so, there's none in xhtml about including stuff. thank you thank you.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There are various methods, but none is really XHTML.

    1) PHP or other script includes.
    2) Server-Side Includes (SSI). You just have to reconfigure your server a bit to make it work.
    These two actually work. The following are theory.
    3) Since XHTML is XML, this should work:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "..." "..." [
      <!ENTITY header SYSTEM "http://mydomain/includes/header.ent">
    ]>
    
    <html xmlns="...">
    <head>
    </head>
    <body>
    &header;
    </body>
    </html>
    The problem is that no browser I know of actually applies external parsed entities.
    4) The XLink specification has a way of directly putting stuff into a document.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <html xmlns="..." xmlns:xlink="...">
    <head></head>
    <body>
    <div id="menu" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" xlink:href="includes/header.xhtml"/>
    </body>
    </html>
    Again, there's zero browser support for this. Mozilla will go farthest in that it might make a normal clickable link to header.xhtml out of this.
    5) XIncludes. This is another way of getting data into a document, and it's just as poorly supported as the other methods.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <html xmlns="..." xmlns:xinc="...">
    <head></head>
    <body>
    <xinc:include href="includes/header.xhtml" parse="xml"><xinc:fallback>
    <h1>Header</h1>
    </xinc:fallback></xinc:include>
    <body>
    </html>
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width