ExpressionEngine

Friday, October 24, 2008

ExpressionEngine Plug-in: UK Counties Select

Another day, another little ExpressionEngine Plug-in. I needed to return a list of UK counties in a standalone entry form. I could have simply flicked on PHP for the template and spewed forth a foreach from an array but I thought I’d wrap it all up in a plug-in instead, so here it is.

The ‘UK Counties Select’ plug-in simply renders a drop down select form element with an alphabetical list of UK counties. Usage of the plug-in is as follows:

{exp:np_uk_counties_select name="counties"}

I could add options to specify a class, id etc but for now this does the job just fine for me.

Download: pi.np_uk_counties_select.php.zip

Obviously let me know in the comments if you have any thoughts on how this can be improved. Enjoy!

Posted by Nathan Pitman on 10/24 at 08:21 AM
ExpressionEngine • (0) CommentsPermalink

Wednesday, October 15, 2008

Migrating from TXP to EE - Step 5

ExpressionEngine does not provide a ‘native’ facility for recording links but the immense flexibility of ExpressionEngine Weblogs allows you to create your own links facility by just creating a new Weblog with the relevant custom fields (Title, URL & Description) and then setting up a related category group.

Just as we exported our article data from Textpattern we ‘could’ also export our Link data and then use the same import process to pull it into ExpressionEngine.

However this is not the route I’m going to take. Personally I would much rather maintain my ‘noteworthy’ links using a tool like Delicious so I’m going to show you how we can migrate our Textpattern links to Delicious and then have them displayed inline within an ExpressionEngine template.

Luckily for us there’s a fantastic Textpattern Extension called ajw_bookmarks that provides us with a quick and easy way to export our Links to a ‘Bookmarks’ file which most bookmark services and browsers can import.

Download and install the Extension within Textpattern and then navigate to the Bookmarks tab within Extensions and select the first option ‘Export bookmarks’.

Now that we have our locally saved Bookmarks file navigate to the Import Bookmarks tool on the Delicious website (obviously you will need to log-in first) and then choose the ‘Custom import’ option.

Now we want our bookmarks to be visible to the public so check ‘make all my imported bookmarks public’. If you wish to use Delicious to record bookmarks for personal use and also for display on your website you may want to tag all the bookmarks you are going to import with a keyword such as ‘noteworthy’ or similar. This is the approach I took. By adding this tag I can identify which bookmarks should be pulled out of Delicious for display on my website. Now click ‘Import Now’.

Delicious should have a bit of a think, depending on the size of your links collection and then display your imported bookmarks.

We’re going to use the ExpressionEngine ‘Magpie’ plug-in to pull our Delicious links into our template and display them inline. The plug-in will also cache the data so if Delicious should go down our site won’t fall apart. The Magpie plug-in is a part of the default ExpressionEngine install so just open up a template file and drop in the following code:

{exp:magpie url="http://feeds.delicious.com/v2/rss/nathanpitman?count=10&tag=noteworthy" limit="10" refresh="60"} <ul> {items} <li><a href="{link}" title="{title}">{title}</a><br /> {description}</li> {/items} </ul> {/exp:magpie}

Obviously you’ll have to replace ‘nathanpitman’ in the feed URL with your own Delicious username and if you want to pull back bookmarks with a particular tag then include the ‘&tag=’ parameter and variable in the querystring as I have above.

You should now have a nice unordered list displaying your 10 most recent Delicious bookmarks or my 10 most recent Delicious bookmarks if you forgot to change the username in the URL. smile

If you need to you can also tweak the number of minutes that the plug-in waits before it refreshes the feed display, I’d opt for 60 minutes. The Magpie plug-in defaults to 3 hours if you don’t specify a refresh value.

Posted by Nathan Pitman on 10/15 at 10:41 PM
TextpatternExpressionEngine • (0) CommentsPermalink

Friday, October 03, 2008

Migrating from TXP to EE - Step 4

Right so, a quick re-cap… we’ve exported our data from Textpattern, imported it into ExpressionEngine and done a quick find and replace to fix up our embedded images.

Next job on our list is to fix up any links to file assets which we have in our entries. Textpattern uses a file download manager which records total file downloads and obfuscates the actual file path in the URL which you place in your entry. ExpressionEngine, whilst being a fantastic CMS, does not provide support for file download counts or obfuscation (here’s hoping for EE2!) which is a shame but hey ho… let’s soldier on.

We’re going to have to repair any links to files in our entries because the two systems link to file assets in different ways. So within the ExpressionEngine control panel navigate to the ‘Edit’ tab and use the search tool at the top of the screen to search for the string ‘/file_download/’ in ‘titles and entries’. This should give you a list of all the entries that you will need to fix up.

Unfortunately we’re going to have to do this manually (unless you can think of a better way!) so download all your file assets from your Textpattern install and then upload them to your file upload destination in ExpressionEngine (Prob best done via FTP).

Now we just need to amend the file paths in our entries so work through the list of entries that contain the ‘/file_download/’ string and replace the old Textpattern file path references with the new ExpressionEngine file path references.

Now, you can either use the ‘copy and paste info’ that the ‘File Manager Module’ provides you with (a standard href link) or hand craft a Textile based equivalent. The choice is yours.

Ok so I ran out of time a little today and didn’t have a chance to explain how we can migrate out Textpattern Links but I promise I’ll cover that in my next post! smile

Posted by Nathan Pitman on 10/03 at 08:33 PM
TextpatternExpressionEngine • (0) CommentsPermalink

Saturday, September 27, 2008

Migrating from TXP to EE - Step 3

Now comes the exciting part. We’re going to import our old Textpattern artcicles into ExpressionEngine!

First off we will need to upload the text file that we generated in our export from Textpattern in Step 2. I just dropped my file into the web root of my server so I could get at it easily from ExpressionEngine.

Once your file has uploaded log-in to your ExpressionEngine control panel and navigate to the ‘Admin’ tab and then ‘Utilities’ and ‘Import Utilities’. We’re going to use the ‘Movable Type Import Utility’.

Complete all the fields on the import screen, your file path should be something like ‘../txpexport.txt’. Everything here should be pretty obvious, I just made sure I un-ticked the ‘Create members from commenters?’ option but obviously you might want to do things differently.

I’d suggest you do a few dry runs first of all with a small export from your Textpattern install to verify that everything is working as expected. I did an export of 10 entries from Textpattern initially just to test and then deleted all the entries and categories before performing my final import.

Ok so we have all our articles imported now but we’re not quite done yet. We need to set up a ‘File Upload’ location for our Textpattern Images. I decided to just use the default ‘Main Upload Directory’ which is already configured in ExpressionEngine.

I downloaded all my image assets from my Textpattern image upload folder and uploaded them all to my ExpressionEngine image upload folder. Now in my case the file paths are different (though you could always mimic the folder location which Textpattern uses in ExpressionEngine. If like me you didn’t you can quickly and easily do a find and replace on all your article image file paths.

Navigate to ‘Admin’ and then ‘Utilities’ and select ‘Find and Replace’. In my case I entered ‘/images/’ in the ‘Search for this text’ field and ‘/images/uploads/’ in the ‘replace with this text’ field. Select the entry field that you want to affect and the click submit.

All of your article entries should now include any inline images or media. Next we’ll be looking at how to deal with Textpattern ‘links’ and ‘file assets’.

Posted by Nathan Pitman on 09/27 at 06:40 AM
TextpatternExpressionEngine • (0) CommentsPermalink

Friday, September 26, 2008

Migrating from TXP to EE - Step 2

So now we have our ExpressionEngine install pretty much ready we need to export our data from Textpattern. At this point it may be wise to upgrade your Textpattern install to the latest release.

During a bit of a forum tennis match almost 3 years back(!) Jon Hicks and I managed to refine an export method which had been used for Textpattern previously to incorporate clean Textile and entry comments. I’ve summarised the steps you will need to take and the code you will need to use in your Textpattern templates below.

Before you start you will need to install a couple of Textpattern plug-ins to ensure that we can get our data out in just the right format.

First is a Textpattern plug-in called msv_show_article_field which is written by Martin Švihla. This plug-in allows us to return the Textile formatted content for the articles instead of the HTML equivalent. This means that our articles will maintain their nice clean Textile formatting once imported into ExpressionEngine. Bonus!

Next is a plug-in called glx_thiscomment which is written by Johan Nilsson. This plug-in allows us to pull out the plain text name value for comments rather than the name wrapped in a ‘href’ linking to the comment authors website URL or email (the default behavior for the built in Textpattern comment tag). This is essential if we want to maintain article comments.

Now create 2 new Textpattern forms, one called ‘export’ and one called ‘exportcomments’. Add the following code to your ‘export’ form:

TITLE: <txp:title /> AUTHOR: <txp:author /> DATE: <txp:posted format="%m/%d/%G %I:%M:%S %p" /> PRIMARY CATEGORY: <txp:category1 /> CATEGORY: <txp:category2 /> <txp:php>echo "-----"."\n";</txp:php> BODY: <txp:msv_show_article_field name="Body" /> <txp:php>echo "-----"."\n";</txp:php> <txp:if_excerpt> EXCERPT:<txp:msv_show_article_field name="Excerpt" /></txp:if_excerpt> <txp:php>echo "-----"."\n";</txp:php> <txp:if_comments> <txp:comments form="exportcomments" break="" /> </txp:if_comments> <txp:php>echo "--------"."\n";</txp:php>

…and the following code to your ‘exportcomments’ form:

COMMENT: AUTHOR: <txp:glx_thiscomment key="name" /> EMAIL: <txp:comment_email /> URL: <txp:comment_web /> DATE: <txp:posted format="%m/%d/%G %I:%M:%S %p" /> <txp:message /> -----

Finally we need to call our ‘export’ form from a page template. Create a new page template called export and add the following code:

<txp:article_custom section="name-of-your-txp-section-here" form="export" limit="500" offset="0" />

Obviously you will need to tweak the parameters in your page template to suit the number of blog entries you have and the section from which you wish to export entries.

With all of the above done we should now be able to visit the public URL for this page template in our web browser (http://yourdomainname.com/export/) and see the output. I had over 400 entries to export so the page took a while to load. Once fully loaded view source and save a copy to a plain text file on your local machine (txpexport.txt for example).

I know I promised to cover how we import this data into ExpressionEngine but I’ve been rambling on for a while now so I’ll leave that until my next post. smile

Posted by Nathan Pitman on 09/26 at 09:16 PM
TextpatternExpressionEngine • (0) CommentsPermalink
Page 1 of 4 pages  1 2 3 >  Last »