Archive for the ‘hack your template’ Category
Magazine style automatically updated WordPress blogs
I’ve been wanting a magazine style template for my main website splash page for about six months. And I’d been wondering how those scrapers, scraped you rss feed into their blog. Sometimes procrastination is a good thing when I finally got around to looking into it all I found most of the pieces had already been written.

Herself’s Green Things picks up the rss feeds from all my websites, turns them into blog posts and posts them in a magazine style theme all automatically.
I tried all the magazine themes I could find on the WordPress theme pages. The Magadine theme was the one that was most stable and easiest to hack so that’s the one I choose. Colors and fonts are very easy to change as are the number of columns and rows. ( change rows and columns in index.php )
<?php
if($count == 2 ) {
echo “<div style=’clear:both;’></div>”;
$count = 0;
}else{
$count += 1;
}
?>
count == 2 will give you 3 columns, count == 1 will give you two, count == 3 gives you four columns.
There are several WP plugins that will turn rss feeds into posts. I chose Syndication which appears to have been pulled by the author because he/she didn’t want spammers using it. That’s a shame, maybe if you ask nicely the coder will give you a copy, I’ll respect the coder’s wishes and not provide copies. I like it best because it turns the title of the post into a link back to the original blog.
There are about a half dozen other choices available on the WordPress plugins site. Try them all see what suits you best. I thought WP-o-Matic and FeedWordPress also did excellent jobs.
After activating your syndication plugin you tell it which feeds to pull and all the ones I looked at gave you several options for credit, links how much of the feed entry to post ect.
Now you shouldn’t have to be told you should only be pulling your own content as I’m doing, or content from other blogs where you have permission. It can be a great way to consolidate your blogs or promote other’s blogs.
You should also only use partial feeds to keep the search engine gods happy, and clicking on the title of the post should take your viewer to the original entry not wandering around the consolidated site.
One problem I had is that I couldn’t fetch 4 of my 13 feeds. I have no idea what or why so what I did was great a Yahoo Pipe of all my blog feeds, then have the syndication plugin grab that feed.
How to add photos from Coppermine to any PHP page
Some asked how to add Coppermine photos to WordPress pages. This code will work for any page.
You need to replace MYSQL_SERVER with your database server, localhost usually works just fine.
USER_NAME is the user name for your Coppermine database
PASSWORD is the password for your Coppermine database
DATABASE_NAME is the name of your Coppermine database
Also replace YOUR_DOMAIN with the domain your Coppermine albums are hosted on. You might also need to change the path.
This code will give you a horizontal table of 3 thumbnail photos.
If you are using WordPress, you need to download any page from your theme. Change the file name to Coppermine and the Template name to Coppermine.
Remove the stuff in the middle. On my template that is everything between<div id=”content” class=”page”> and </div> but your template might be different. The past this code into that section being sure to add your password, database etc.
When you are done, upload the new template to your theme directory.
Create a new page and choose Coppermine as the template. All the work is done. You can add text or anything else to the page.
<?php
if ( !($coppermine_db = mysql_connect( “MYSQL_SERVER”, “USER_NAME”, “PASSWORD” ))){
die ( “Can not connect to server” );
}else{
//select db
if ( !(mysql_select_db(“DATABASE_NAME”, $coppermine_db ))){
die ( “Can not select database” );
}
}//ask mysql db for the path and file name of last five images uploaded
$coppermine_query = “select filepath, filename, ctime from cpg_pictures order by ctime desc limit 3;”;$coppermine_result = mysql_query($coppermine_query);
$count = mysql_numrows( $coppermine_result );//start link
$link = “<center>”;$link .= “<table border=3>”;
$link .= “<th colspan=3><a href=\”http://YOUR_DOMAIN.com/coppermine/\”>Recent Photos</th><tr>”;
$i = 0;
while ( $i < $count ){$path = mysql_result($coppermine_result, $i, “filepath” );
$name = mysql_result($coppermine_result, $i, “filename” );$link .= “<td><img src=\”http://YOUR_DOMAIN.com/coppermine/albums/$path” . “thumb_$name\”></td>”;
$i++;
}$link .= “</tr></table>”;
$link .= “</center>”;//end link
//clean up
mysql_close();print $link;
You can see an example of this code TimesToCome where I pull 3 photos from 3 different Coppermine albums onto the page.