www.webdeveloper.com
Results 1 to 14 of 14

Thread: Automatically update links on pages

  1. #1
    Join Date
    Mar 2005
    Posts
    7

    Unhappy Automatically update links on pages

    Hi,
    On my site I have 22 pages, and on each page I have links to all the others. So when I add, edit or remove a page I have to edit all 22 pages. I was wondering if there was a way to have the links kept in one file on my server, and have the links from that file show up as links on all my pages.

    Thankyou

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Best way is server-side, see thread

  3. #3
    Join Date
    May 2004
    Posts
    442
    If you enable PHP on your host, it really is extremely simple to do what you are saying.
    All you need is an include file with the links defined as constants.
    For example, if you want to reference index.htm then think of a name to call it, home say, then create a text file called something like "links.inc" and define home as a constant who's value is index.htm

    <?php
    define ('home','index.htm');
    ?>

    Just add more lines for more constants.

    Then in your html pages you then place the line
    <?php include(links.inc) ?>

    And in each html file you replace each link with the appropriate constant..

    <?php echo home; ?>

  4. #4
    Join Date
    Mar 2005
    Posts
    7

    Using Framesets

    I have found that I can use Framesets to have a different page that I just show after the main page. How do I make it show up UNDER the main page, but off screen untill I scroll down to where it would be if it were one page...

  5. #5
    Join Date
    Oct 2004
    Location
    Portland, OR
    Posts
    145

    Don't use framesets

    Framesets are EVIL!!! very bad business... avoid... avoid... avoid... 666 - mark of the beast - etc... I've dealt with them before, I thought they were "easy to manage". The best way to go is php includes.
    -Mike

  6. #6
    Join Date
    Mar 2005
    Posts
    7

    Hmm

    I use them on another of my sites and they are fine, but I guess they cant do this...

    I have never, NEVER used php before. I don't get how to use it.

    I have done what was previously said, but How do I replace the link?

  7. #7
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Check first if your provider supports PHP, if so then start with this tutorial

  8. #8
    Join Date
    Mar 2005
    Posts
    7

    Argh

    Doesn't work.
    Last edited by Swiftless; 03-25-2005 at 01:05 AM.

  9. #9
    Join Date
    Jul 2003
    Location
    New York City
    Posts
    2,771
    http://webdevfaqs.com/php.php#include

    It's really rather simple. Include all your links in a separate document. Name it whatever you like, links.txt or what-have-you. Now, in your pages, make sure it's got a php extension (.php instead of .html) and where you want the links to be, put this:

    <?PHP include('links.txt'); ?>

    Simple as pie. If you know how to bake.

  10. #10
    Join Date
    Mar 2005
    Posts
    7

    Hmm

    Ok, I figured out how to do it using the unclude function, given above.

    Although this does not do what I want, I still have to manually add links to every page. I want it to just list all the links from the links.inc file, at the bottom of every page.

    links.inc looks like this:
    <?php
    define ('home','<a href="index.htm">Home</a>');
    define ('contact','<a href="contact.htm">Contact Us</a>');
    ?>

    and to test it, main.php looks like:
    <?php include("http://home.austarnet.com.au/caradonhouse/down.htm") ?>
    <?php include("http://swiftless.thefreebizhost.com/Test/hmm/links.inc") ?>
    <?php echo home; ?>
    <?php echo contact; ?>

    but i want it to echo all the files in the links.inc at once, instead of all manually as you can see with:
    <?php echo home; ?>
    and
    <?php echo contact; ?>

  11. #11
    Join Date
    Jul 2003
    Location
    New York City
    Posts
    2,771
    Why are you doing that? Just put the html into the include file. Thus:

    links.inc
    Code:
    <a href="index.htm">Home</a>
    <a href="contact.htm">Contact Us</a>
    <a href="http://example.com">Other Links</a>
    Main.php:
    PHP Code:
    <?PHP include('links.inc');?>
    And you're done.

  12. #12
    Join Date
    Mar 2005
    Posts
    7

    Yay

    Because up above they told me to do that

    That works perfectly, thankyou so much.

  13. #13
    Join Date
    Mar 2005
    Posts
    7

    ARGH ARGH ARGH

    I just found out that the page CANNOT have an extension of .php, as this will stop all search engines and links to the site from working. Is there any way to leave the name of the page as .html?

  14. #14
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Try this

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles