Hard coding your ping URL in ExpressionEngine.

As requested, I’ve set up a category on EE tips, tricks, hacks, how-tos and so on that I manage to come up with that other folks would like to know how to do. First up is how to hard-code the URL used to ping services like Blogrolling.com. Why would you want to do this? When you first set up a blog in EE you’re asked to define the URL for the blog. The assumption most folks make would be you’d use the root domain such as https://stupidevilbastard.com/. The problem is there are a few functions under EE, such as the built-in search engine, that don’t work quite right if you only use the root domain. Any searches with the root domain configured returns links that don’t point to the proper location such as https://stupidevilbastard.com/this_is_an_article/. The fix is to put in a URL that includes the index and template category such as https://stupidevilbastard.com/index/seb/ and then the search function will return proper links.

However, now when your blog pings services such as weblogs.com or blogrolling.com it uses this longer URL so anyone who has your site blogrolled with the shorter URL (https://stupidevilbastard.com/) won’t see a notification that you’ve updated because the URL you pinged with is the longer version (https://stupidevilbastard.com/index/seb/). Rick Ellis has said that this will be addressed in version 1.1 by allowing you to define what URL are used for various functions. I’m assuming this means there will be at least two configuration options—one for the search function and one for the ping function. Until then, however, there is a work-around you can use:

Open up system/cp/cp.publish.php and look for the function labeled:

//————————————————-
// Send Pings
//————————————————-

Rick says it’s around line 1850 or so. Then add $blog_url = “http://yourdomain.com/”; someplace in the function. I put it right underneath the $sql = line like so:

$sql = “SELECT server_name, server_url, port FROM exp_ping_servers WHERE”;
$blog_url = “http://yourdomain.com/”;

This hard codes what URL is used to ping the various services you’ve defined and it works great, but there is a catch. If you’re running multiple blogs like I am then ALL of them will ping as whatever you’ve hard coded here. So when my sister updates her blog instead of pinging as http://cindy.jenkinsonline.net/ it’ll ping as SEB. If you’re only running one blog then this isn’t an issue, but in my case I’m working on a bit of PHP code that will check for which blog is pinging and shorten the URL accordingly. If I manage to cobble something together before version 1.1 is released then I’ll update this entry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.