How to convert theme to BlogEngine.NET part 2

Wednesday, 8 September 2010 21:52 by rtur.net

Search Magnifier This is a second in the series of tutorials on theme building with BlogEngine (go to part one). This time I’ll get search functionality up and running. BlogEngine has search widget and server-side control to add search really easy to the blog, but for some themes it does not fit well with design and you want to go manual. Fortunately, it is not hard.

Getting Search working

This is search form as it is implemented in Boldy (JavaScript that makes it work omitted):

   1: <div id="topSearch">
   2:   <input type="submit" value="" id="searchsubmit"/>
   3:   <input type="text" id="s" name="s" value="type your search" />
   4: </div>

And this is all you need to make it work with BlogEngine:

   1: <div id="topSearch">
   2:   <input type="submit" value="" id="searchsubmit" onkeypress="BlogEngine.search('');" onclick="BlogEngine.search('');"/>
   3:   <input type="text" value="<%=BlogSettings.Instance.SearchDefaultText%>" 
   4:     onblur="$(this).animate({width: '100'}, 300 ); BlogEngine.searchClear('<%=BlogSettings.Instance.SearchDefaultText%>')"
   5:     onfocus="$(this).animate({width: '215'}, 300 ); BlogEngine.searchClear('<%=BlogSettings.Instance.SearchDefaultText%>')"
   6:     onkeypress="if(event.keyCode==13) return BlogEngine.search('')" id="searchfield" />
   7: </div>

As you can see, you can submit search by simply calling JavaScript function search(‘’) - as long as text box with id= “searchfield” exists on the page. That frees our hands completely and we can implement pretty much any design in any theme very easily. Point to notice is that if your site is in the server root (“http://your.site.com” rather than “http://your.site.com/blog/”) , you would pass slash as an argument to search function: search(‘/’);

searchClear() does obvious thing - clears the box from default text when you click into the field and restores when you move out.

Nice little touch with search box sliding out is done with jQuery - if you don’t have jQuery installed on your blog and don’t want it - remove calls to “animate” from code above or you’ll get JavaScript error on the page.

Last but not least, we need to add control to theme’s master page where results will show up. Here is what the end result for main section looks like:

   1: <div id="colLeft">
   2:   <blog:SearchOnSearch ID="sos" runat="server" />
   3:   <asp:ContentPlaceHolder ID="cphBody" runat="server" />
   4: </div>

As usual, alongside goes CSS tweaking to make search results look nice. This time it is literally few touches to pad text and add a line separator.

As a bonus, I added date/author/category/tag/comments stab to the post title. Not much to explain there - take a glance at PostView.ascx in the theme folder if you interested in details.

Another change was “prettifying” comment form - I believe comments section is responsible for half of success or failure of any blog and you can’t spend too much time making it better. It wasn’t very hard and all I did was adding background image and changing CSS styles, but I can clearly see that there lots of space for improvement here on BlogEngine’s side. It got to be much more flexible and better yet form itself be a control in the theme’s folder much like CommentView or PostView.

One curious detail I ran into was styling “county” drop-down with background image. Turns out, Chrome does not support it - at least I could not make it work in that browser and from what I read in support forums it just does not do it period. Bummer.. Ended up removing it from the form all together. I used ugly hack to do it - looking up IDs in the FireBug and setting display to “none”. Again, having form as a template in the theme would make it so much cleaner. If it does not work for you - and it might - you’ll need to check IDs generated by ASP.NET on your site and make a correction. Here is mine:

   1: #cphBody_CommentView1_imgFlag, #cphBody_CommentView1_ddlCountry, .commentForm label[for="cphBody_CommentView1_ddlCountry"]{
   2:   display:none;
   3: }

Updated “Boldy” can be downloaded here:

Boldy2.zip (267.76 kb)

Tags:   ,
Categories:   Themes
Actions:   E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

How to convert theme to BlogEngine.NET

Sunday, 5 September 2010 22:34 by rtur.net

boldy With summer behind us, you might want to change things a little bit to celebrate a new season. Like buy a new shoes or, may be, change a theme on the blog. I decided to do the later. My schedule is quiet busy, so I’ll do it in several steps and will share tips, tricks and findings with anybody interested.
I’m running relatively recent build of BlogEngine from source, but new theme should work fine with 1.6.x.x. Let me know if it doesn’t for you and I’ll do adjustments as needed. To start, I went looking for catchy free theme, no kind in particular - any design can be adopted to BlogEngine pretty easily. This WP theme looked pretty good to me. Below I’ll try to document adoption process step by step.

Laying down the foundation

  • First download original design. It can be WP theme, generic CSS template or anything else - as long as it is HTML/CSS/JavaScript we should be fine, back end does not matter.
  • In the BlogEngine site, copy “standard” theme and rename copied to “Boldy”.
    Move all CSS, images and JavaScript files from original to newly created BE theme.
    Override “style.css”.
  • Go to simplest page in the demo site (like this for example) and right-click/copy page source. Paste it into site.master and remove all server-side code from site.master.cs.
  • Clean up copied HTML. For now you’ll need add only two things from standard site.master in there: directives from the very top (2 lines) and content placeholder (cphBody) where list of posts will show up.
  • Check out download link at the end of this post to see how simple theme files really are after you clean them up.

Lining up comments and forms

Some CSS skills are required. FireBug is a big help. Mostly what you do here is looking through the FireBug at HTML generated by BlogEngine and apply appropriate style to it. Usually theme you are trying to adopt comes with some style for forms and sometimes comments, but HTML elements, class names etc. do not match. Probably best way to go is remove all form/comment related CSS and gradually move form/comment CSS from BlogEngine into new theme. Obviously, some things you’ll like to change to match new design. Easily most time consuming task in this first step.

Checking out archive

Copying “archive” section from “standard” theme almost did it, just a few minor changes and it looks the way I wanted.

Minor tweaks to content CSS

Depending on your content, you might notice that some things from your previous theme does not look quite right. I spent some time tweaking image display and few others playing with “float”, “margin” and alike.

Get a logo

Go to creatr and get yourself a little silly logo. Why not? It’s fun and easy!

You can download original Boldy theme here and theme adopted for BlogEngine using link below. It is far from done and you probably don’t want to put it on your blog just yet, but looks pretty good already. In the next steps I’ll get “search” working, add widgets and do a lot more to bring this theme to live.

Boldy.zip (257.51 kb)

Tags:   ,
Categories:   Themes
Actions:   E-mail | Permalink | Comments (1) | Comment RSSRSS comment feed

How To Contribute Code To BlogEngine.NET

Thursday, 3 June 2010 17:05 by rtur.net
codeplex

BlogEngine is a CodePlex-based project and uses Mercurial as source control. Most of described below equally applied to any CodePlex project that uses Mercurial. Here is step-by-step what you need to do to share your code on CodePlex. More...

Tags:   ,
Categories:   BlogEngine
Actions:   E-mail | Permalink | Comments (15) | Comment RSSRSS comment feed

Flickr Widget Updated

Friday, 28 May 2010 22:15 by rtur.net

FlickrBar

Few people mentioned that my FlickrBar widget for BlogEngine.Net got out of sync with Widgets framework after framework got interface change. I have updated widget to work with latest releases including 1.6.0 and 1.6.1, you can download it using link below. Instruction on how to use are dead simple: move files in the corresponding location and widget will pop up as an option in the zone dropdown. Go to “edit” and enter what kind of photos you want streamed down to your blog, set number of photos to display, may be change CSS (for example, use “padding:2px” to get gaps between pictures). You can see end result on the right side bar in my blog.

FlickrBar.zip (38.25 kb)

Tags:   ,
Categories:   Widgets
Actions:   E-mail | Permalink | Comments (7) | Comment RSSRSS comment feed

This is hot!

Tuesday, 11 May 2010 17:56 by rtur.net

hot_list

Sorry about post title, could not resist :) You probably saw these "new" and "hot" links next to list items all over the place. Something was added or updated and it makes sense to put an indicator that clearly shows this. I wanted to do it for list of extensions on BlogEngine site, so that when something new added anyone could see it right away, because list is pretty large. And I don’t want to maintain it afterwards, that image should go away when it is not “hot” anymore, all by itself. How hard is this with BlogEngine and .NET? Walk in the park: More...

Tags:   ,
Categories:   Extensions
Actions:   E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

Desktop vs Web Email Clients

Friday, 9 April 2010 20:49 by rtur.net

email About a month ago I re-discovered that you can actually run email client on desktop and unexpectedly liked it. That is odd - I distinctly remember some kind of pain associated with this activity in the recent past, so I tried to sort this out. Mainly for myself, but may be someone else will find this useful or amusing. Desktop client I'm talking about is Windows Live Mail. It is free and light weight, generally you install it with new OS as part of Essentials package. More...

Tags:  
Categories:   Reviews
Actions:   E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

Disqus and reCaptcha integrated with BlogEngine 1.6.0.5

Saturday, 3 April 2010 18:02 by rtur.net
 

image All improvements to comment management outlined in this post completed and now available in source control, so if you wish to give it a test drive I really interested in your feedback. This includes both Disqus and reCaptcha integration (credits go to Hamish Graham and Filip Stanek respectively. The plan is to make it finalized and available for download as service pack or optional update in the next couple weeks. By then, there are going to be testing, refactoring an clean up but hopefully no major changes. More...

Tags:   ,
Categories:   Spam Protection
Actions:   E-mail | Permalink | Comments (14) | Comment RSSRSS comment feed

How to add folder with mp3 files to music library

Saturday, 20 March 2010 15:10 by rtur.net

image Friend of mine sent me course of lectures recorded as mp3 files. All files untagged and named alphabetically. I decided to add folder to my music library to listen it on iPod. Should be easy. Now, here is a quick quiz: what will happen if you open some popular music management software, say iTunes or Zune, and do “add folder to the library” thing? More...

Tags:   , ,
Categories:   General
Actions:   E-mail | Permalink | Comments (6) | Comment RSSRSS comment feed

Improving comment management

Friday, 26 February 2010 16:53 by rtur.net

tune-up

Looking at stats in several BlogEngine.Net 1.6 based sites, it seems like Akismet scores around 80% in accuracy on average, killing some 8 out of 10 spam comments. Which is pretty good but not outstanding. "Stop forum spam" filter blocks may be another 5%. Still, quite a lot of spam comments get through the filters. More...

Tags:   ,
Categories:   Spam Protection
Actions:   E-mail | Permalink | Comments (17) | Comment RSSRSS comment feed

Custom Filters in BlogEngine 1.6

Saturday, 6 February 2010 10:33 by rtur.net

custom

Spam comments are annoying and sometimes looking at comment allowed by Akismet or some other anti-spam service you think – I’m sure I would do better. It is just so hard to get the plumbing in or I would made my very own solution. With BlogEngine.Net 1.6 it is not, you can easily implement your own anti-spam filter or add existing if you like it more than built-in Akismet. Here is how. More...

Tags:   , ,
Categories:   BlogEngine
Actions:   E-mail | Permalink | Comments (6) | Comment RSSRSS comment feed