• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Something I am Looking For

Dan

Bullah
NLC
I know this is possible because I have seen it done before. Just need to know how.

I am currently creating a website right? On the site, on each page, there is a section that will display the "Recent Updates" or "Recent Additions" or whatever.
Now, instead of changing each page individually, I want to enter the text to a document on the server for the latest news. Example: latestnews.txt and once saved, it will change the Latest News content on each page of the website.

Hope that makes sense.

Does anyone know how this is done?
 
Id say u can use either php include or the HTML equivalent
somthing like #include virtual="filename"

I dunno, im just a newbie :p
 
I do something like this with my site. The current sale and nav bar are using the following code

Code:
<?php include("filename.php"); ?>

Then filename just contains what you want it to say.

Php is the best way imo instead of the html method. I mean who dosnt have php these days? :p
 
Thanks Tracker mate.
I guess I will be able to use PHP.
However, if the site is coded in HTML, what method would I use? Like, obviously, I wouldn't use <?php include.......?
 
PHP:
<html>
<head>
<!-- other tags. -->
</head>
<body>
<?php include("nav.php"); ?>
<!-- other content -->
</body>
</html>
 
Thanks Dynash. I appreciate that mate.
I just didn't think PHP code would work in a simple HTML layout.
Would I need to save the extention as .php rather than .html for that to work?
 
I just didn't think PHP code would work in a simple HTML layout.
Would I need to save the extention as .php rather than .html for that to work?
PHP is server side, HTML is client side - they're entirely compatible..
Not necessarily:
Code:
AddType application/x-httpd-php .html .htm
For example in the server configuration file (or an .htaccess file) will parse .htm/.html for you using php.
 
Well if you really wanted to keep it as .html you could always add a .htaccess

Code:
RemoveHandler .html .htm .shtml
AddType application/x-httpd-php .php .htm .html .shtml
 
As tracker said both times

A simple include would be your best choice and if you wanted to keep it html .htaccess is there to assist with that.

You could always do it via database tho :)
 
This is the HTML equivalent i think.

Code:
<!--#include virtual="filename.html" -->

Requires SSI
 
Well if you really wanted to keep it as .html you could always add a .htaccess

Code:
RemoveHandler .html .htm .shtml
AddType application/x-httpd-php .php .htm .html .shtml

can't say I think this is a wonderful idea, means *all* your html pages are parsed through php. This slows down everything.
 
can't say I think this is a wonderful idea, means *all* your html pages are parsed through php. This slows down everything.

From what dan was saying all the pages on his site were going to have said code there for that would have worked. Admittedly it would just be better to change the pages to .php
 
Ok this is not working for some reason.

It worked earlier with a test.php and a test.txt file but now I am trying it on a live site and I get the following:

PHP:
Warning: include(panel.txt) [function.include]: failed to open stream: No such file or directory in /home/danriord/public_html/index.php on line 68

Warning: include(panel.txt) [function.include]: failed to open stream: No such file or directory in /home/danriord/public_html/index.php on line 68

Warning: include() [function.include]: Failed opening 'panel.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/danriord/public_html/index.php on line 68

Now, I changed the page to index.php and created panel.txt and inserted some stuff in there.
I placed the following where I wanted the text to show in index.php:
PHP:
<?php include("panel.txt"); ?>
but it won't work.

NVM. It's working now. :)
 
Last edited:
Ok this is not working for some reason.

It worked earlier with a test.php and a test.txt file but now I am trying it on a live site and I get the following:

PHP:
Warning: include(panel.txt) [function.include]: failed to open stream: No such file or directory in /home/danriord/public_html/index.php on line 68

Warning: include(panel.txt) [function.include]: failed to open stream: No such file or directory in /home/danriord/public_html/index.php on line 68

Warning: include() [function.include]: Failed opening 'panel.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/danriord/public_html/index.php on line 68

Now, I changed the page to index.php and created panel.txt and inserted some stuff in there.
I placed the following where I wanted the text to show in index.php:
PHP:
<?php include("panel.txt"); ?>
but it won't work.

NVM. It's working now. :)
Your file wasnt there :)

Good to know its working now.
 
Back
Top