Tag Archives: tutorial

WordPress: Fixing the broken links from Jetpack top stats

I use the upgraded awesome plugin Jetpack by WordPress.com to show the ‘Top Posts’ is the sidebar. I recently noticed that the links for these post were broken, even though I wasn’t doing anything wrong at all. I queried the plugin for top 5 posts using:

$top_posts = stats_get_csv('postviews', 'days=-1&limit=6&summarize');
echo '<ul class="most-viewed">';
  foreach ( $top_posts as $p ) {
      echo '<li><a href="'. $p['post_permalink'] .'" title="'.
        $p['post_title']. '">'. $p['post_title'] .'</a> - <strong>'. $p['views'] . '</strong> views</li>';
echo '</ul>';

But somehow, the value at post_permalink key was wrong. Instead of pulling out my hair, I downloaded the Jetpack plugin’s source code, opened the file stats.php and copied a few lines and now the following works awesomely well.

if ( function_exists('stats_get_csv') && $top_posts = stats_get_csv('postviews', 'days=-1&limit=6&summarize')) {
  echo '<ul class="most-viewed">';
  foreach ( $top_posts as $p ) {
    if($p['post_id'] && get_post($p['post_id']))
      echo '<li><a href="' . get_permalink( $p['post_id'] ) . '">' .
          get_the_title( $p['post_id'] ) . '</a>', number_format_i18n( $p['views'] ) </li>';
  echo '</ul>';

I hope this helps people looking for a quick fix to this problem.

Drupal: Tutorial for Feeds Image Grabber

Feeds Image Grabber (FIG) was released on 3rd March, and currently supports the following features:

  1. Automatically downloads and attaches image to the node created by Feeds module.
  2. Configurable XPath of the desired image location on the webpage of the feed item on per feed basis (using element’s id or CSS class).
  3. Support for FileField Paths module.
  4. Configurable maximum image size.
  5. Configurable minimum and maximum image resolutions.

In this post, I will briefly demonstrate how to configure the settings for FIG to efficiently grab images for feed items.
Continue reading

Dumping a remote SVN repository without admin access

When you need to dump a SVN repository, all you have to do is

svnadmin dump REPOS_PATH

But wait, then you need to have admin access to the server on which your SVN repository is hosted. Often, that is not the case and you have to contact the company which hosts your repository to do it for you. I have a repository hosted at CVSdude and I needed to dump it. As I am on the Developer Edition plan, I do not enjoy the privileges to backup my repositories from my admin panel. I could have mailed the guys at cvsdude, who according to me are quite supportive and quick to respond, but that would have taken longer than what I am going to describe next.

SVN provides a unique utility, svnsync which is a Subversion remote repository mirroring tool. Put simply, it allows you to replay the revisions of one repository into another one. Now, we can create an empty repository on our local system, synchronize it with the remote repository and then dump the local repository. Follow the following 4 step process to have a dump of your repository:
Continue reading

Tutorial for FeedAPI Image Grabber


I get a lot of requests for this, so here is a tutorial explaining the 3 W’s (What, Why and How) of FeedAPI ImageGrabber.


a feed item from google reader

a feed item from google reader

This is a screenshot of a news item from my Google Reader. Anyone who has a moderate knowledge about the feeds would know that the image on the left in the above news-item is actually not published with the feed.

In other words, If you refresh any feed on your Drupal website using FeedAPI, you won’t get the image in the posts, unless they are published along with the feed which is quite rare.

The purpose of FeedAPI Imagegrabber is to make the feed more informative as well as interesting for the user. As, we all know that “comics are much better than novels”, this module appends the feed-item with an appropriate image from its content URL. The goal of the FeedAPI ImageGrabber is to mimic the thumbnail display of Google Reader for the feeds on your Drupal website.

As soon as you refresh the feed, ImageGrabber automatically attaches an appropriate image from the original article to the feed-item node on your website. You don’t even have to press an extra button!!

Continue reading