New Blog and a New home


Well, I decided it was about time that I moved my blog home, so here it is, and while I tried a few things, I was amazed at how easy the transition went. I was able to import my WordPress blog without any major incident, and all the comments came across without any dramas. There is one snippet that I used for ModX, and that was a new one I created called: fix_blog_paragraphs The content looks like this:
/* Written by Stephen Monro 2015
This Snippet is used to fix the WP blog entries. Yep, it's a dirty hack, but is essential if you don't want to edit a 100 blog posts.

Function taken from http://tinyurl.com/nmeol6n
/*

$string_name = $scriptProperties['string_name'];
return nl2p($string_name);

function nl2p($string)
{
    $paragraphs = '';

    foreach (explode("\n", $string) as $line) {
        if (trim($line)) {
            $paragraphs .= '<p>' . $line . '</p>';
        }
    }

    return $paragraphs;
}
So basically, the problem is that WordPress when you edit (which I only found out from importing everything) is that it doesn't appear to store the <p> tag. This isn't so much a problem, but it makes the formatting on articles look terrible. Yep, this is basically a <CR> to <p> or carriage-return to paragraph converter for ModX. So to solve this, I made the snippet above. To use it, you simple called it like so in your template and bingo, your articles will look good again. [ [!fix_blog_paragraphs? &string_name=`[ [*content] ]` ] ]

Comments (0)


Add a Comment





Allowed tags: <b><i><br>Add a new comment:


Latest Comments