Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Dynamic a href in HTML - Help

  1. #1
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default Dynamic a href in HTML - Help

    I am working on a large static website (xHTML) - i need to know if there is a way to have the links in the "a href" tags dynamic - i.e., something like an xml file - if i change it in one place, it should get reflected all over the site. This is a static html website - please help.

    Thanks.

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You can use php include for this:
    PHP Code:
    <?php
    include('http://www.me-myself.com/externalcode.txt');
    ?>
    Put that code where you want it to be displayed.
    externalcode.txt file:
    Code:
    <a href="http://www.dynamicdrive.com/">DD</a>
    Of course you could use javascript or inline frames for this as well.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  3. The Following User Says Thank You to Snookerman For This Useful Post:

    me_myself (12-08-2008)

  4. #3
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default

    Should it only be a php include? Is there anything like a html include - cause i dont think i can convert all the pages to php (php includes will work only if i convert the pages to php - right?).

    Please let me know if there is anything like a html or a txt file include - that would make my life a whole lot better

  5. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You can still use include in html files. All you need to do is add this to your .htaccess file:
    Code:
    #RemoveHandler .html .htm
    
    #AddType application/x-httpd-php .php .htm .html
    
    AddHandler application/x-httpd-php .html .htm
    If you don't have a .htaccess file you can just open Notepad and add that code in the blank page and save it as .htaccess (not file.htaccess or anything else, just .htaccess). Upload the .htaccess file to your server and you're good to go with the include.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  6. The Following User Says Thank You to Snookerman For This Useful Post:

    me_myself (12-08-2008)

  7. #5
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default

    Snookerman, thanks a lot for the reply. One more question - should i have one include (html) files for one link or can i have one include for all the link and in that html have links for all the a href items?

    Thanks

  8. #6
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You can pretty much include anything: plain text in a .txt file, a .html page, images, .asp, sounds, etc. That's what makes include so great.
    So you can put the whole part of your website that you wish to update into the .txt file.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  9. The Following User Says Thank You to Snookerman For This Useful Post:

    me_myself (12-08-2008)

  10. #7
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the very useful info.

  11. #8
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default

    snookerman, what would be the syntax if i used a html or a txt file as an include?

    I tried <!-- #include virtual="filename.html" --> but it doesn't work.

    Thanks

  12. #9
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Have you tried this:

    PHP Code:
    <?php
    include('filename.html');
    ?>
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  13. The Following User Says Thank You to Snookerman For This Useful Post:

    me_myself (12-10-2008)

  14. #10
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default

    After having this php include, the file name should be changed to filename.php or can it be filename.html?

    Thanks

Tags for this Thread

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
  •