So you have a really long list of blogs. But you only want a select few to show up on your main page, because that list is just too long and it overwhelms your site.
Here's how you do it (in php)…
Make your list of blog links – one blog link per line. You can even have little decorative characters around the links… Like, on Christine's blog, she has those little "::" before each link. Just make sure you don't have extra returns in there…
then add this code where you want your random blog links to show up:
<?
$array = file("/path/to/your/file/bloglinks.php");
shuffle($array);
for ($i=0; $i<10; $i++) {
echo $array[$i];
}
?>
This will show 10 random links on your page. Change the "<10" to <20 or <25 or however many you want to show…
assumptions:
1) you've named your file: bloglinks.php
2) you're able to run php scripts on this page
————————————
in case you don't want to read through the comments – I've moved this code into the main post…
If you want to alphabetize that list:
<?
$array = file("/path/to/your/list/of/blogs/bloglinks.php");
shuffle($array);
for ($i=0; $i<10; $i++) {
$miniarray[$i] = $array[$i];
}
sort($miniarray);
for ($i=0; $i<count($miniarray); $i++) {
echo $miniarray[$i];
}
?>
and make your bloglinks file look like this:
<!– A life uncommon –> <a href="etc etc.
<!– Blahblahblog –> <a href="etc. etc.
Additional note: if it seems like you're list is being pulled in completely, and you're on a Mac – there is something about text files edited on a Mac where the "returns" aren't read as "returns" by the server… you might want to try this method:
Between each blog line add "|||" so your list would look like this:
<!– a life uncommon –> <a href="http://a.lifeuncommon.com">a life uncommon</a><br>|||
<!– big pink cookie –> <a href="http://www.bigpinkcookie.com">big pink cookie</a><br>
etc.
Then where you want your list to show up, use this code:
<?
$link_array = file("/path/to/your/list/of/blogs/bloglinks.php");
$link_array2 = implode("", $link_array);
$link_array3 = explode ("|||", $link_array2);
shuffle($link_array3);
for ($i=0; $i<10; $i++) {
$miniarray[$i] = $link_array3[$i];
}
sort($miniarray);
for ($i=0; $i<count($miniarray); $i++) {
echo $miniarray[$i];
}
?>
(change that "10" in the code above to the number of links you want to display)