Editing content on multiple pages

Discussion in 'Programming' started by TodoRojo, Sep 6, 2012.

to remove all ads.
  1. TodoRojo

    TodoRojo New Member

    Messages:
    7
    Hey everybody, I'm new to the forum and one of the main reasons why is because I find myself wondering how I can do something and never finding a great answer!

    I searched around and wasn't able to find what I'm looking for (if it's on here, forgive me! just link it please!)

    Basically on my site I have an "About the Author" part of the page and instead of having to change every page every time I update it, I'd like to be able to use PHP and link it to a text file that I can edit whenever I want to edit (or something to that effect). Any help or hints or places to look would be great! Thank you!
     
  2. TodoRojo

    TodoRojo New Member

    Messages:
    7
    Found something quite simple to use!

    <?php
    $about = file_get_contents('nameoffile.txt');
    echo $about;
    ?>
     
  3. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,651
  4. Roddy

    Roddy New Member

    Messages:
    117
    "Included" in the web design software that I use is an "Includes" function for local files. This a separate folder containing all the files that you would want to include in more than one page such as the header content, navigation, footer stuff etc, javascripts and so on.

    The "master" copy can be updated and then the pages are updated by using the "Update Includes" function in the Insert menu.

    You may also want to look at the W3.org site and read about the iframe "seamless" attribute.
     
  5. Nullified

    Nullified New Member

    Messages:
    25
    Here ya go (Very Basic)

    index.php:
    PHP:
    <?php
    define
    ('THIS_SCRIPT''home');
    require_once(
    'includes/global.php');
    include(
    'header.html');
    ?>
    <div id="body">My Main Content Goes Here</div>
    <?php include('footer.html'); ?>
    header.html:
    HTML:
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <div id="header">My Header Goes Here</div>
    
    footer.html:
    HTML:
    <div id="footer">My Footer Goes Here</div>
    </body>
    </html>
    
     
  6. waynewade

    waynewade New Member

    Messages:
    1
    Even i was searching for the same code over Google but found here.
     
  7. JoshuaReen

    JoshuaReen New Member

    Messages:
    15
    I agree with you. This is quite simple and easy to use for this purpose. Thanks for sharing it, today I have learned something new here. :)
     

Share This Page