Simple WordPress Columns

24/08/2011

Recently I needed to display some content in WordPress in two columns, I couldn’t find any easy way of doing this, other than going nuts in the wysiwyg editor.

So I wrote some simple code to get some quick and dirty columns within a wordpress page/post. I may turn this in to a dirt simple plugin, but for now this has sorted my basic need. There may well be an easier way to do this, and if you know of one, please feel free to let me know via the comments.

The shortcode is [columns][/columns] and it requires the the ‘more’ element of the wysiwyg to be used to ‘split’ the columns.

[code lang="html"]
[columns]
Content for column 1
Read the rest of this article »

No Comments

mysql: save query to file

11/07/2011

Courtesy of @BenjaminDavies

mysql -u [username] -p [dbname] -e [query] > query.txt

No Comments

my big list of things to do

4/05/2011

So now that I’m getting on a bit, I’m starting to panic about not fitting in all the stuff I wanted to do with my life before I get old, I think others call this a mid-life crisis.

I started writing this list about a year ago, although I haven’t particularly spent much time on it, mostly been jotting things down as and when they come to me, however, I thought I may as well bung the list on line so people can laugh at me and see how much of a loser I really am.

The list is about 50 or so items at the moment and I intend to expand on this as I see fit. I haven’t added all items from my list to the online version, as some are too personal to share.

Of the items I have shared, some are tiny, some are big, some are ridiculous and some are a bit embarrassing. However, I think all of them are achievable, hence why there’s no ‘fly to the moon’ or anything on there.

So it may take me 5, 10, 25 years to complete the list, and it will be expanding as I get older, but I think it will be useful to have a list of things to achieve, I’m scared to death of being old and regretting how I lived my life.

I’ve closed the comments on this post as the actual page itself has comments on, so please add any comments you want to that.

Yep, I’ve given this bad boy it’s own page, and now the moment you’ve been waiting for (or more likely scrolled down to see) the link to my big list of things to do with my life…

http://lifelist.jenkins-web.co.uk/

I’ve added a progress bar to the list to keep track of how much I actually achieve, at the time of writing, I need to pull my bloody finger out!

No Comments

tools for freelance collaboration part 1: project management

9/02/2011

So, I don’t really do much freelance, I do bits here and there, whenever I get asked really, but I find myself continually searching for tools to use and help me, particularly when collaborating with another developer, or more commonly, a designer.

I’m gonna write a series of posts on the search for these tools, what I find good, bad etc…

Like I said I’m a bit part freelancer, so if I miss out some tools (likely) or you feel there are better things to use as to what I suggest then let me know and I’ll take a looks.

part 1: project management

Warning: cheesy ass stock image coming up (its the cheesiest I could find)

Cheesy Project Management Stock Image

The few freelance projects I do are nearly always a collaborative effort, usually between a designer and myself. I always find myself at the start of the project searching for a decent project management tool to assist us in this collaboration. So for the first part in this series, I’ll be looking at project management tools to keep everything organised and as a way to make it easier between myself and the designer (or other developer).

My requirements for this were thus: -

  • must be free – I don’t do enough freelance to justify paying a monthly fee or anything
  • must have somewhere to dump files
  • must have milestone support
  • must have task creation and assignment support
  • must have a dicussion board or similar
  • must have to do list support
  • code repository would be a bonus
  • issue tracking would also be a bonus

Here are the apps I have tried up until now…

huddle – http://www.huddle.com

pros

- good calendar
- nice idea of workspaces
- whiteboards is very cool
- excellent file support

cons

- has gone under a redesign since, but when I looked at it, it was very busy and confusing
- almost too many features
- it seems free accounts have gone? only free account is a limited trial period it seems
- no svn support
- no issue tracker

basecamp – http://basecamphq.com

pros

- simple to use
- excellent support for to do lists
- excellent milestone support
- super cool writeboards
- excellent messaging system
- free option
- can integrate with the other 37 signals apps and has api which lots of other systems hook into if you need things like svn support etc..

cons

- free option is very limited
- no native svn support
- no native issue tracker
- mention the word gannt chart and they may kill you*

* This is untrue, they will not harm you in any way

teamlab – http://teamlab.com

pros

- task and milestone creation is nice and easy
- file sharing is excellent
- good dicussion feature
- time tracking with useful reports feature
- simple and smart interface
- free!
- nice instant messaging feature

cons

- dashboard can be a little confusing, particularly if you have more than 1 project
- no svn support
- no issue tracking support

reverb – http://reverbapp.com

pros

- free
- looks beautiful
- easy to use
- file sharing support
- dicussion support
- milestones and tasks work a treat
- did I mention it looks nice?

cons

- limited to 10mb of space
- no svn support
- no issue tracker
- no option to upgrade to get more space etc.

unfuddle – http://unfuddle.com

- free option
- svn support!!
- issue tracking support!!
- milestone support
- dicussion support
- tasks (through tickets) and milestone support
- plenty of options to upgrade should you need to

cons

- free option is quite limited
- ajaxified to the point of it almost being annoying
- the ticketing is excellent but it almosts takes away the essence of project management through tasks and setting timeframes

conclusion

If you require svn (or git) support and/or a decent issue tracker as an all in one solution, then unfuddle is definitely worth a look. The problem here is the limits of the free account. What you may find yourself doing is hosting your subversion/issue tracker yourself or separately and just looking for a kick ass project management tool.

If this is the case, then I don’t think you can go wrong with any of the above, if I was pushed to pick one, I might be tempted to go for reverb, but that’s just me being a sucker for a pretty web app.

freedcamp

I have only just come across this one, and haven’t really had chance to use it before this blog post, but it looks excellent. The fact that it seems to be focussing on a free project management tool for “people who just love to collaborate on ideas”, suits me down to the ground. If I get chance to have a proper look and play, I will update this post I’m sure.

2 Comments

useful bits when using wordpress as a cms

18/01/2011

What a catchy blog post title :-?

Anyways, been working on a wordpress cms site and have found a few bits and bobs useful, so thought I’d blog about it. Mostly for my own benefit for future reference, but if someone can make use of it, then cool.

useful plugins

Found the following plugins very handy when using wordpress as a cms…

cms – The hint is in the title, but it’s really excellent. It basically removes all the confusing cruft that wordpress has in order to focus more on it’s CMS bits. Simplifies the admin massively and allows you to turn things off in the admin such as posts/comments etc.

cms page tree view – Another must for a cms wordpress. Allows you to view the pages in a tree like structure. It does it really nicely too, with nice little hovers and a clean, simple interface.

more fields – The site I was working on required a sidebar which contained lots of different bits of functionality. Images, content, lists etc. This plugin allows you to specify different fields to use for different sections. It is based around custom fields, but makes them so much easier to use and manage and gives you things like a content editor for them.

wp list tweets – Like every site in the world right about now, I needed to list the latest tweets. There are hundreds of plugins to list tweets, but I found this one was the smallest, simplest and did exactly what I wanted to with minimum fuss. Basically you chuck it a twitter username and it displays the latest X tweets, simples.

cleaner gallery – A gallery page was also required for the site and I found this gallery plugin excellent. The lightbox integration is particularly useful.

wp contact form – Needed a small and simple contact form, again there are lots of contact form plugins, but they all seemed to complicated for my liking. This one is dead simple, the only drawback is that it has no anti-span functionality, so if your site has a fair bit of traffic and you don’t want spam, maybe this isn’t for you. However, there do seem to be re-hashed versions of this which have anti-spam features such as captcha included.

tubepress – There were a ruck of videos on a youtube channel, which needed to be brought into the website and displayed in a gallery. This plugin does exactly that. Nice.

exclude pages – Dead simple, if you want to exclude a page from the navigation, this allows you to do so.

setting it up

Did the following things in the admin in order to make it work. The site I was working on was to be used primarily as a cms with a single page being used for it’s blog.

settings > reading

Front displays as a static page with my ‘home’ page set as the front page and my ‘blog’ page set up as the posts page. Home and blog are just the names of the pages, they could be named whatever.

cms plugin settings

Only turn on the posts component. Only because I needed to have a blog page, otherwise this would have been turned off also.

more fields plugin settings

- New input box ‘Sidebar’.
- Used only for pages (not posts)
- Added sidebar-image field as a file-list. A file list is a dropdown of media items.
- Added sidebar-title field as a text box. This allows the administrator to add a title in the sidebar (duh!)
- Added sidebar-content field as a content editor. This allows the administrator to put whatever the hell content they want in their sidebar (to appear under the sidebar image and title)

custom theme

I created a custom theme, just to keep all the stuff I was doing neatly contained within its own theme. For this I used Elliot Jay Stocks Starkers Theme. I can’t recommend this highly enough. If you are creating a theme from scratch, then use this theme as a base, done.

codes fiddlings

Mostly amends to the sidebar. I was never going to use the widgets on the sidebar, so if you are, then my changes may not be that advisable.

So here is the code I added to my sidebar.php. You can read the code comments to see what’s going on. Also, note that the mismatch of code and html is not something I’d encourage, but this is wordpress remember.

		<?php
		global $wp_query;		

		/**
		 * If we are on a single blog page or a blog category page, we won't
		 * have the blog listing page within wp_query. So use the get_option()
		 * function to get the page id of the page we specified to list posts.
		 * Otherwise we can get the page_id from the wp_query.
		 */
		if (is_single() || is_category()) {
			$page_id = get_option('page_for_posts');
		} else {
			$page_id = $wp_query->queried_object->ID;
		}		

		/**
		 * Get our custom field sidebar-image and display that shit
		 */
		if ($sidebarImage = get_post_meta($page_id, 'sidebar-image', true)) {
		?>
			<div class="sidebar-image">
				<img src="<?php echo $sidebarImage; ?>" alt="Alt text here" />
			</div>
		<?php
		}
		?>

		<?php
		/**
		 * Sidebar content we want to display latest tweets if on the home page,
		 * otherwise show the sidebar title, sidebar content and any children pages
		 * we may have
		 */
		?>
		<div class="sidebar-content">

			<?php
			/**
			 * If we're on the homepage, then we want to show the latest tweets.
			 */
			if (is_front_page()) {
			?>
				<div id="footersm" style="padding-top: 10px">
            		<a href="http://twitter.com/yourtwitteraccount" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/twitter-20x20.png" alt="Follow us on Twitter" title="Follow us on Twitter"></a>
            	</div>
				<h2>@yourtwitteraccount feed</h2>
			<?php
				wp_list_tweets();
			} else {
			?>

				<h2><?php echo get_post_meta($page_id, 'sidebar-title', true); ?></h2>

				<?php echo get_post_meta($page_id, 'sidebar-content', true); ?>

				<?php 

				/**
				 * Wanted to list children pages in sidebar, so check if the current
				 * page has a parent and if so, get the root page id.
				 * Otherwise just use the current page_id as the parent
				 */
				if ($wp_query->queried_object->post_parent)	{
					$ancestors = get_post_ancestors($page_id);
					$root = count($ancestors)-1;
					$parent = $ancestors[$root];
				} else {
					$parent = $page_id;
				}		

				/**
				 * wp_list_pages() will get us list of pages under a certain page_id
				 */
				wp_list_pages( array( 'child_of'=>$parent,
					'title_li'=>'',
					'depth'=>1 ) );
			}
			?>
		</div>

Needed to bring out the latest 2 posts on the homepage as well, wanted to keep code to a minimum and not introduce any functions/classes, but if you have a better set up than me then put this in your functions file or better still a nice little helper class or something, but here is what I used to pull out latest 2 posts on the home page…

                    <?php if ( is_front_page() ) { ?>
                        <div id="latest-posts">
                            <?php
                            /** Set up our options, i.e. 2 latest posts */
                            $options = array('numberposts' => 2,
                                                'orderby' => 'post_date',
                                                'order' => 'desc');
                            $i = 1;
                            foreach (get_posts($options) as $post) {
                            ?>
                                <div class="post num-<?php echo $i; ?>">
                                    <h3><?php echo $post->post_title; ?></h3>
                                    <span class="date">Posted on <?php echo date("D, j M Y", strtotime($post->post_date)); ?></span>
                                    <div class="content">
                                        <?php echo (strlen($post->post_content) > 200) ?
                                            substr($post->post_content,0,200).' <a href="'.get_permalink($post->ID).'">Read more...</a>' : $post->post_content?>
                                    </div>
                                </div>
                            <?php
                                ++$i;
                            }
                            ?>
                        </div>
                    <?php } ?>

And, that’s pretty much it! Nothing too advanced or crazy, but just some useful things for me to remember for next time. I’m also not quite finished, so I may add to this list.

6 Comments

2011 please kick 2010′s ass

31/12/2010

2010 wasn’t a great year for me and I fully intend on not letting that happen again in 2011. I basically need to upgrade to Jenko v2.0. Unfortunately, as with most major upgrades, their will undoubtedly be some downtime whilst this occurs.

Anyway here are (20)11 things I need to try and keep to in 2011 to ensure it’s not another shitfest. Some may call them resolutions, but I’m going for the much more catchy ‘things I should stick to in order to have a better year’.

If you can’t be arsed to read the entire (depressing) list then in short, in 2011 I want to try and achieve something I failed to in 2010. Happiness.

1. find some confidence

For various reasons, my confidence has taken a bit of a battering in 2010. I need to regain my confidence and start being awesome again.

2. be less selfish, but more self centred

Not sure if this should be the other way round or not, but the point is, I need to start looking after number one. I often put other people before myself and I need to stop doing that, I get little reward for it. On the other hand, there have probably been times in 2010 where I have been too selfish, this needs to stop also. I appreciate this seems a bit contradictory but it makes sense to me…kinda.

3. stop being ‘nice’

Linked to the above, but I’m kind of bored being the nice, safe guy all the time. I don’t wanna become a dick, but I want to start enjoying life more and if this means pissing off a few people on the way, then I need to stop worrying about that. Being ‘nice’ just seems to be an open invitation for people to take advantage of you.

4. have more fun

I can probably count on one hand the number of times I had real, laugh out loud, fun, in 2010. Life’s too short for that, I need to take steps to make sure I have fun.

5. take in more live music

Finally one that’s not mega depressing! Historically I’ve not gone to many gigs, mostly due to costs and effort I think, but I need to start taking in more live music in 2011. I saw Imogen Heap at the tail end of last year and absolutely loved it. I’ve booked to go see Ben Folds, but there are plenty of other gigs I wanna go to, so I need to put my hand in my pocket and get out there.

6. properly learn the piano

Ok, I learnt ‘Frère Jacques‘, big deal, I need to start learning proper songs.

7. socialise more

Again, due to various reasons, I didn’t socialise much in 2010. This sucks, because socialising is like totally rad. I need to go out with friends and colleagues much more often in 2011.

8. take an exercise class

This is like a proper resolution. Loads of reasons this is a good idea. A friend recommended I try yoga due to my stupid ass back problems, but I’m also tempted by the bike one, ermm what’s it called, can’t remember, but you’re on an exercise bike and there’s music and someone shouting at you.

9. read more

Yep, pretty self explanatory.

10. take a frickin’ holiday

I need to go abroad and take in some sun, not happened in over 3 years, not sure I can handle another holiday within this country. Winning £2.50 on a 5p gambler should be a lowlight of a holiday, not a highlight! An option is to go stay with my friend who’s just moved to Hong Kong. His name is Tony Wong, and he lives in Hong Kong…chyer I know!

11. finish a personal project!

If you go into the root directory of my home web server there must be about 30 folders of personal projects I’ve started but not finished. I get loads of stupid ideas of web apps and stuff, I write a bit of code, get bored and never finish it. I need to finish one of these some day.

Ok, I think that’s everything, a bit depressing, but there you go, onwards and upwards, 2011 you have a lot to live up to!

3 Comments

staying motivated during a large project

1/03/2010

mr-motivator
I will try to keep this as brief as possible so you’re not left thinking you need to read an article about staying motivated during a large blog post!

I am nearing the end of a particularly large development project. The project has been over a year in development and seen a number of developers working on it.

When working on a project for this length of time it is easy to find yourself losing motivation for the task at hand. Obviously this is undesirable, because as we all know a motivated worker is a productive one.

So how do you maintain motivation during this mammoth task and keep yourself from losing your sanity?

Well, there are few ways I found that helped a great deal and I would like to share these with you..

1. Break tasks down into small chunks

Perhaps an obvious one but by breaking behemoth tasks into small achievable steps you instantly increase the motivation. The smaller the step the better. Spending a few days on something small does not weigh you down as much as having to spend months on one laborious task.

2. Share the workload

Having a massive project solely on your back is not nice and will only damage the project. By choosing a number of developers to work on the task you instantly remove the pressure of one person having to deliver. This doesn’t mean throw your whole dev team at the problem, but simply share tasks based around spare time in the developers schedule. You should determine the development team for the project at the start of the project and it is important to note that if the project is running late, adding more developers to it is not the answer.

3. Use the right tools

Using things like version control and a good issue tracker are always good practice, but they become even more important when you have multiple developers working on a large project. By using the right tools you will ease the pain that can often arise when multiple developers are working on a project and thus increase the motivation of the developers working on it.

4. Take a break

There’s nothing more de-motivating that getting stressed over a particular task. If things are getting stressful or you are struggling with a particular problem, take a break. You would be amazed what 5 minutes away from the screen can do. You often find coming back to a problem with a clear head can solve it almost instantly.

5. Forget about it

Said in my best american/italian gangster accent, ‘fuggedaboutit’. Don’t take work home, try not to think about the project when not in work. Make sure you spend your weekends doing something as far away from the project as possible. This allows you to come in fresh the next day refreshed and motivated to get on with your (small) task.

This list is by no means exhaustive, but like I said, I tried to keep it as brief as possible. Indeed there are many things you can learn and take from working on a large project and I tried to make the experience a positive one rather than a negative one.

No Comments

tips for life

23/09/2009

On the 21st November 2009, my son, George, will be 1 year old. Just before he was born I had an urge to write down all the things in life I wish I had been told before I embarked on this mad little journey. However, because I’m a lazy arse, I never got round to it.

So now that his first birthday is fast approaching, I’m about to get all philisophical and share my tips for life. In this first post I will list all of my tips, I will then elaborate on each one in subsequent posts.

It is also worth noting that I left out some obvious points such as ‘Live every day as if its your last’ and ‘Life’s too short’, these I consider to be pre-requisites!

I want to give a bit of recognition to an excellent post which inspired this one a little bit. So make sure you check out 100 ways to live a better life.

And finally, here are my tips for life:

  1. Silence often says more than any words.
  2. Learn something from every single person you meet.
  3. Be kind and sharing but ultimately be selfish.
  4. Support Liverpool F.C.
  5. Don’t take yourself (or anything for that matter) too seriously.
  6. If you’re happy, carry on what you’re doing, if you’re unhappy, change whatever it is you’re doing.
  7. Be humble.
  8. Appreciate how lucky you are.
  9. Be confident.
  10. Ask questions.
  11. Be reflective.
  12. See the good in everyone.
  13. Rise above adversity.
  14. Support Liverpool F.C.
  15. Don’t take things personally or get defensive.
  16. School will be the best years of your life despite how you feel at the time, but remember school is only a small part of your life.
  17. Enjoy being a child/don’t grow up too quickly.
  18. Observe.
  19. Do things for you.
  20. Support Liverpool F.C.
  21. If you cant say anything nice dont say anything at all.

Now listen to this classic (lyrics).

No Comments

do the simple things well

17/04/2009

If any young web developer (of which I am one myself) should be stupid enough to ask me for advice, it would be to do the simple things well.

When I was an up and coming footballer (soccer-er), many a coach told me to ‘do the simple things well’. A player who can control the ball well, pass the ball simply and do all the basics well will get a lot further than the player who tries to do too much, tries to take on too many players and tries to score the perfect goal.

Of course there are the odd exception to the rule, but then even players who are known for their skills such as Ronaldo have benefited from being reigned in a bit. Alex Ferguson is often credited with turning Ronaldo from a spectacular player with no end product to an all round superstar (for the record I hate Ronaldo, Fergusan and all thgins Manchester United).

Going back to my original point, if you can do the simple things well then you can go places. This is not only true for football of course, but is also true with web development and indeed most things in life.

Here come the acronyms

Unless you have been living under a web development rock for the last decade you will be familiar with the term KISS. Just to remind us this stands for Keep It Simple Stupid. As much as it is now a bit of a cliche (and I hate Cliche’s) never has an acronym rung so true.

I would take a web developer who comments their code well, organises things well with sensible directory structure and naming schemes over some web developer ‘guru’ who ignores these assets any day.

It all boils down to what makes a good web developer. Where some people may argue that experience and a good understanding of advanced methodologies make a good web developer, I think all of this is in vain if they cannot do the simple things well.

It is true and some what essential that you are constantly learning new things and expanding your knowledge on a daily basis, but this will all be built on a better grounding if you can do the basics and indeed the simple things well. In effect you don’t want to leave any demons behind when you move on to the next stage of your development as they may come back and bite you in the ass.

2 Comments

spotify = music heaven

19/01/2009

I recently started using spotify after I saw someone I was following on twitter rave about it, and all I can say is…awesome.

logo

Spotify is basically a music player, much like itunes, where you can search tracks and listen to music. The greatest thing about spotify is that you can listen to (almost) any track in the world! It is just like having your own personal radio. You even get the annoying adverts, which in actual fact, aren’t nearly as annoying as you might think. You hardly notice a short audio advert, and I much prefer it to having a great big flashing banner hit me in the face whilst searching for tracks.

It’s catalogue of tunes is seriously huge, imagine having an ipod with every song in the world (almost) on it and that’s what spotify is. What makes it even more great, is a sweet ass interface and search.

it even scrobbles!

Yep, after numerous requests and attempted plugins, spotify finally added last.fm scrobbling support. This is a killer feature for me as I am a keen user of last.fm. Would love to see more last.fm integration, such as being able to ‘love’ a track directly form spotify, but then we get in to the realms of just recreating last.fm, which is not what it’s trying to do.

If you haven’t checked out spotify then I urge you to, invite only at the moment for the free version (I got 4 invites left, drop me a comment if you want 1). If, like me, you spend all day at a desk, listening to tunes whilst you tap away at a keyboard, then this is perfect for you.

No Comments