Have you ever wanted to easily replace some text or an image just by
uploading a file? This can be accomplished by using placeholders and
the php "include" function. The include function loads a file and
possibly executes any php commands it finds.
Here's a quick page layout I created to demonstrate the use of
placeholders and using php to display the content of an external file.
The 3 black squares are placeholders and each will load a different file.
The first placeholder loads a file called news.php which only contains:
This is the latest news.
The second placeholder file named news2.php has some html in it:
<p><font color="red"><strong>This is the news box
2</strong></font></p>
The last placeholder names news3.php has both html, css styling, and
does some simple addition using php:
<p style="font-family:Verdana, Geneva, sans-serif; font-size:24px">3 + 3
= <? echo 3+3; ?></p>
The above screen shot shows the the code you would enter to load a
file called news.php. <?php or just <? for short is the tag to indicate
the start of php while the ?> indicates the end of php. The semi-colon
indicates the end of a command and is required. The file name should
be in quotes.
The other placeholder content is identical except for the name of the
file, which uses news2.php and news3.php respectively. The files
themselves could have other extensions, .txt or .html, for example and
still work the same. The files are relative so in this case would be in
the same directory as the file loading them, in this case index.htm file.
Now time to see the results. I published my page with a name of
index.htm to my test directory, which will also show that my server is
parsing htm and html files with the command I entered in the .htaccess
file. I created the news files using a standard text editor and uploaded
them via ftp using an ftp client. The screenshot below shows the
results:
Through a recommendation, I purchased Xara XXP4 and joined the TG
forum back in 2008. I am NOT a graphic designer and have no such
talent. Xara is great for the drawing-impaired as I often use it for
resizing graphics, saving in different file formats, tweaking existing
graphics, and of course doodling or doing a tutorial which is the only
way I'll be able to create something halfway presentable.
I enjoy going to the TG forum as an art enthusiast would enjoy a trip to
a museum and enjoy the "master pieces" presented on the forums.
I wish to thank Gary for the opportunity to contribute and give back a
little.
I have owned and operated LotsMoreHosting.com since 2008 providing
shared hosting, VPS, and dedicated servers to my clients. I also project
manage development of complex php based websites.
Chris K. Houg
Send e-mail