[thelist] PHP Includes for Random Sidebar Boxes
jono at charlestonwebsolutions.com
jono at charlestonwebsolutions.com
Thu Mar 2 07:37:02 CST 2006
I am trying to find an efficient way to randomly insert the following
snippet of html into a page's sidebar:
<div id="sidebar">
<!-- START: Sidebox -->
<div class="sidebox">
<div class="boxhead-pressrelease">
<h3>Example Headline</h3>
</div>
<div class="boxbody">
<p class="press">Example paragraph appears here...</p>
<p class="link"><a href="example.php">Click Here</a></p>
</div>
</div>
<!-- END: Sidebox -->
</div>
I have about 6 different sidebar boxes I would like to randomly insert in
my pages. Ideally, I would only like to have two or three sidebar boxes
in each page's sidebar.
I am very new to PHP and includes, but I think that an include can do the
trick as follows:
1. Save each snippet of html for the 6 boxes in a directory called sb-boxes
2. Name each snippet sb-box1.inc, sb-box2.inc, sb-box3.inc, and so on
3. In my page(s) add something like the following:
<div id="sidebar">
<!-- START: Sidebox -->
<?php include('http://path/to/sb-boxes'); ?>
<!-- END: Sidebox -->
<!-- START: Sidebox -->
<?php include('http://path/to/sb-boxes'); ?>
<!-- END: Sidebox -->
</div>
I know that the include code above will not do any randomizing, that is
just as an example of how I think it might possible work. How do I go
about inserting the snippets randomly using this, or a similar approach?
MSN, Google, and Yahoo turned up a ton of results, but I am not proficient
enough with PHP to weed out the good from the bad. IS this as easy as and
light weight it seesm it should be?
--
Jono Young
Designer | Developer | Illustrator
Charleston Web Solutions
Bringing Higher Standards to the Lowcountry
http://www.charlestonwebsolutions.com
More information about the thelist
mailing list