December 6, 200817 yr Hi, I'm currently putting together a large website (50+ pages) and there is going to be a section on every page with featured content in it. Is there I way I can make the featured content editable on one separate html file so all of the pages will show the same thing? Can this be accomplished without using an iframe? I've been investigating using: <link rel="section" href="featured.html" type="text/html" media="screen"/> Will that work? Thanks in advance, Sam
December 7, 200817 yr Author Can you give me some more information, i don't really have a very good knowledge of php
December 7, 200817 yr If you look on the tutorials section on this forum, there are a couple on this topic. A php include is very simple...not like the rest of php so don't worry. Also have a look on w3schools. I can explain to you how it is done...but I think others describe better. I hope this helps, if not I can pm you an example.
December 7, 200817 yr Author Thanks I haven't really done PHP before and I was under the impression it was v. difficult.
December 7, 200817 yr PHP is not easy, it's certainly more challenging than HTML - but using includes is a VERY simple bit of PHP functionality that you can add to your sites. simply add this <?php @include ('path/to/file/filename'); ?> bear in mind, if the included file is VITAL to the site's operation (i.e: navigation) you might want to use the require command instead. There are some security risks involved in using includes, but they're possibly negligible if they are the only dynamic part of your site. Just do a Google for includes to get a better understanding of them.
December 7, 200817 yr Thanks I haven't really done PHP before and I was under the impression it was v. difficult. php includes are really quite simple. the below code would be put where you want your required content to go <?php include("yourfile.html"); ?> that little line of code would be put on every page that requires it. then by updating yourfile.html you are effectively changing every page containing the above code. Y ou will have to add the .php extension to every page containing that code eg if you put that code into your index.html page you would have to change it to index.php. Hope that makes sense Pat
December 7, 200817 yr Ah, before you do all that, and it doesn't work... PHP files (you should save any files that have php elements with a .php extension) will need to be processed by a PHP enabled server. If you just drop a php file into a regular browser, it won't read the PHP elements correctly. You can test this locally by installing PHP and Apache (or XAMPP, WAMP). You then need to save any php files in the 'root' directory of the application that serves your pages (in the case of WAMP, that's a folder called 'www' - you can change this folder by editing the php.ini file, but I just use that folder as my root dev folder by default). My recommendation would be to install WAMP. Then, copy all your site files into the 'www' folder. Boot up WAMP, and it'll add a little icon to your tray - launch "localhost" from there, and it should take you to the WAMP launch page, which will contain a link to your site. If you open it up using this link (or the path 'http://localhost/yoursite') it should process the include function correctly. Of course, if your target server doesn't have PHP enabled, it won't process the site correctly either, and this usually requires a slightly higher rental cost than a base webhosting solution.
Create an account or sign in to comment