dcsimg
www.webdeveloper.com
Results 1 to 7 of 7

Thread: add in "news flash" type add on to HTML page

  1. #1
    Join Date
    Jan 2017
    Posts
    5

    add in "news flash" type add on to HTML page

    I came into this forum when I asked google [add in "news flash" type add on to HTML page]

    What I want to do is modify a two of more HTML web pages, then by just writing one extra page (whatever) the text from that page gets automatically displayed on to all the HTML pages that got modified.

    I am not sure if my basic PHP knowledge will do the answer without some untidy looking window in the page. also should I learn XML (if that is the way to go)


    By the way
    The reply I got from google link did not work


    if this a repeat just delete it, not sure if I finished posting question

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,586
    Using PHP to do it (if I understand "it" correctly) is certainly a viable option -- if your pages are created as PHP pages. The simplest way is with the PHP readfile() function.

    news.txt (or whatever you want to call it):
    HTML Code:
    <div id="news">
    <h2>News<h2>
    <p>This file has your news in it, marked up as HTML
    that you want to use in your web pages.</p>
    </div>
    some_page.php:
    PHP Code:
    <html>
    <head><title>Example</title></head>
    <body>
    <!-- stuff you want in the page markup before the news section -->
    <?php readfile('path/to/news.txt'); ?>
    <!-- stuff you want in the page markup after the news section -->
    </body>
    </html>
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Jan 2017
    Posts
    5
    Unfortunately NogDog they are all already HTML pages. so this is the problem. otherwise I may of come up with a solution similar to your answer.

  4. #4
    Join Date
    Jan 2017
    Posts
    5
    Um what is this Sempervivum? how strange.

  5. #5
    Join Date
    Oct 2013
    Location
    Sheboygan, Wisconsin
    Posts
    894
    Quote Originally Posted by eric@auckland View Post
    Um what is this Sempervivum? how strange.
    Forum error caught him. And when they hit you, forget everything.

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,586
    It is possible to process files with .html suffixes as PHP (or with any other suffixes for that matter), as long as you can modify the web server config -- which could be done with a local .htaccess file in your site's directory if running Apache, something like:
    Code:
    AddType application/x-httpd-php .html .htm .php
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  7. #7
    Join Date
    Jan 2017
    Posts
    5
    Quote Originally Posted by NogDog View Post
    It is possible to process files with .html suffixes as PHP (or with any other suffixes for that matter), as long as you can modify the web server config -- which could be done with a local .htaccess file in your site's directory if running Apache, something like:
    Code:
    AddType application/x-httpd-php .html .htm .php

    OK I put a file called .htaccess at my website but I had to change the contents of the file to

    AddType application/x-httpd-php html htm php

    (remove the 3 dots)

    Now that was the only way I could get a file.php to come up when I put http://www.website.com/file.html

    But then my website visitor recorder stopped working, so I put everything back to normal,
    (the website visitor recorder is written in PHP and records information the a text file (filename.txt))

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