Somehow it all fits together.
  • 08
  • May, 08

How I converted Mephisto to WordPress

I got a comment the other day asking how I converted to WordPress from Mephisto while keeping my comments and everything intact. If you are familiar with Ruby on Rails, this response will make sense. If you are not, I recommend learning it…then this response will make sense.

In a nutshell, I used Mephisto for the conversion. First I spent about a week mapping Mephisto’s DB to WordPress’ DB. I went straight into the Mephisto Rails project and created a new model that pointed to my newly created WordPress database. I then created a controller in Mephisto that looked exactly like this:

(note: if this is a pain to read, you can also view it here)

class MephistoController < ApplicationController
def index
start_time = Time.now
logger.info ‘querying mephisto articles’
@articles = Content.find(:all, :conditions=>”article_id IS NULL”)
logger.info ‘querying mephisto comments’
@comments = Content.find( :all, :conditions=>”article_id IS NOT NULL”)
logger.info ‘querying mephisto taggings’
@taggings = Tagging.find(:all)
logger.info ‘querying mephisto tags’
@tags = Tag.find(:all)
logger.info ‘processing terms’
for tag in @tags
@wp_term = WpTerm.new
@wp_term.term_id = tag.id
@wp_term.name = tag.name
@wp_term.slug = tag.name.downcase.gsub(” “,”_”)
@wp_term.term_group = 0
@wp_term.save
end
logger.info ‘processing term relationships’
for tagging in @taggings
@wp_tr = WpTermRelationships.new
@wp_tr.term_taxonomy_id = tagging.tag_id
@wp_tr.object_id = tagging.taggable_id
@wp_tr.save
end
logger.info ‘processing term taxonomy’
for tag in @tags
c = Tagging.count(:all, :conditions=>”tag_id = #{tag.id}”)
@wp_tt = WpTermTaxonomy.new
@wp_tt.term_taxonomy_id = tag.id
@wp_tt.term_id = tag.id
@wp_tt.taxonomy = “post_tag”
@wp_tt.parent = 0
@wp_tt.count = c
@wp_tt.save
end
logger.info ‘processing posts’
for article in @articles
c = Content.count(:all, :conditions=>”article_id = #{article.id}”)
@wp_post = WpPost.new
@wp_post.ID = article.id
@wp_post.post_author = 1
@wp_post.post_date = article.published_at-7.hours
@wp_post.post_date_gmt = article.published_at
@wp_post.post_content = article.body
@wp_post.post_title = article.title
@wp_post.post_category = 39
@wp_post.post_status = “publish”
@wp_post.post_status = “open”
@wp_post.ping_status = “closed”
@wp_post.post_name = article.permalink
@wp_post.post_modified = article.updated_at-7.hours
@wp_post.post_modified_gmt = article.updated_at
@wp_post.post_parent = 0
@wp_post.guid = article.published_at.strftime( “http://blog.gillumiante.com/%Y/%m/%d/”)+article.permalink
@wp_post.menu_order = 0
@wp_post.post_type = “post”
@wp_post.comment_count = c
@wp_post.save
end
logger.info ‘processing comments’
for comment in @comments
@wp_com = WpComment.new
@wp_com.comment_ID = comment.id
@wp_com.comment_post_ID = comment.article_id
@wp_com.comment_author = comment.author
@wp_com.comment_author_email = comment.author_email
if comment.author_url == nil
comment.author_url = “”
end
@wp_com.comment_author_url = comment.author_url
@wp_com.comment_author_IP = comment.author_ip
@wp_com.comment_date = comment.published_at-7.hours
@wp_com.comment_date_gmt = comment.published_at
@wp_com.comment_content = comment.body
@wp_com.comment_karma = 0
@wp_com.comment_approved = ‘1′
@wp_com.comment_parent = 0
@wp_com.user_id = 0
@wp_com.save
end
logger.info ‘finished!’
end_time = Time.now
@lapsed = end_time-start_time
render :layout=>false
end
end

I then proceeded to visit the /mephisto/index page on my mephisto blog, which fired this baby off. It took all of about 9 seconds to complete.

I realize the irony of using Mephisto in order to abandon it. But in the end, I wasn’t switching from the Rails based app because of Rails, but because of the app. I am still in love with rails and as you can see, this project would have taken me a lot longer to accomplish had I attempted to write it in PHP, the language of WordPress.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Facebook
  • e-mail
  • StumbleUpon
  • Technorati
  • TwitThis
  • 02
  • May, 08

Safari CSS Hack

I just came across an article about how to write CSS only visible to Safari 3.0 and Opera 9. It saved my life so I thought I’d share the love! It was especially useful to me while trying to use ‘display: inline;’ to create a horizonal nav out of an unordered list <ul>. It turns out Safari and Opera would prefer to see ‘display: inline-block;’ instead, which the other browsers don’t like at all. Now before you go test this, I will say that the only reason ‘display: inline;’ wasn’t working for me in Safari/Opera is because I’m trying to throw a background-color behind each list item <li> and pad it so that the color flows around the outside. Safari/Opera wouldn’t let me pad the list items unless they were set to inline-block.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Facebook
  • e-mail
  • StumbleUpon
  • Technorati
  • TwitThis
  • 19
  • Mar, 08

Wordpress pretty permalinks working on WestHost

I had a hard time figuring out how to get the pretty url permalinks working for WordPress on WestHost, but I finally found the solution. It was weird at first because WordPress actually was writing to the .htaccess file correctly, but when I tried it out in a browser I was still getting 404’s. After a long extensive search on the WordPress website, I finally found that I had to add the following to my httpd.conf file:

    <Directory /var/www/html/wordpress>
        Options FollowSymLinks
        AllowOverride all
    </Directory>
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Facebook
  • e-mail
  • StumbleUpon
  • Technorati
  • TwitThis
  • 15
  • Mar, 08

My Blog is Now Running on WordPress

Well, it’s my second migration. First I built this blog on my own using php. Then I decided to venture out and stop re-inventing the wheel and use a real blogging software tool. I chose Mephisto at the time (about a year ago), but I eventually regretted that and am now completely content with WordPress. I doubt I will ever switch again. I have researched it well this time and talked to professional bloggers who have researched it well. WordPress is king.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Facebook
  • e-mail
  • StumbleUpon
  • Technorati
  • TwitThis
  • 04
  • Mar, 08

Add a field to Contact Us form in Drupal

I needed to add a checkbox to Drupal’s Contact Us form for a client of mine. The client requested that I add a way for those filling out the form to request a newsletter. I discovered it’s pretty easy to add a form field and get it added as part of the email that’s sent. You just need to hack into the module on your server (sorry, no GUI for this). Here’s what I did:

First, find the module file: modules/contact/contact.module

If you prefer command line editing open up that file in your favorite editor. If you prefer the download/edit/upload approach via FTP that will work also. I assume if you have interest in this article, that you have some knowledge of either of those 2 methods. If not, I wonder how you set up Drupal in the first place.

Now that you are in edit mode, find a chunk of code that talks about not allowing anonymous users to send themselves a copy for spam reasons. Found that comment? Good, now just above it you are going to add your field. I found it easy to copy/paste an existing form element and edit it’s contents, but you can type it out if you like. Actually, feel free to copy/paste and edit my example below. Here’s what I ended up with:

 $form['newsletter'] = array('#type' => 'checkbox',
    '#title' => t('Sign me up for the Newsletter'),
  );

You may want to add a comment somewhere in there to remind yourself at a later date that this is no longer part of the original configuration.

That was easy, now I just need to tell it to add content to the email sent out so that when that box is checked, it actually does something! Next look for a chunk of comment code that looks like this:


// Compose the body:

below that you will find a couple lines that start with “$message[] =” which is where the body of the email’s message gets created. Just add another line that says something like the following:

 if ($form_values['newsletter'] == 1) {
    $message[] = "Yes, please send me a newsletter";
  } else {
    $message[] = "No, please do not send me a newsletter";
  }

Now crank open your form and test it out. Assuming you are the recipient of the email being generated, you will get a nice extra piece of text at the bottom of the email with this new content based on the user’s input.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Facebook
  • e-mail
  • StumbleUpon
  • Technorati
  • TwitThis