Coming soon…

I’ve been learning a lot of hands-on technical things lately.

Recently made the switch from Drupal 6 to 7 (I’ll probably write some technical posts about that), started playing around with Drupal’s REST services module (useful, but poorly documented – I’ll write about that too!), and am in the process of putting together a Firefox toolbar for a project (hopefully released to the public soon).

The toolbar will be heavily integrated with a Drupal website, including login control. That was an interesting challenge, since Drupal uses cookies to manage sessions, and javascript (at least in modern browsers) won’t allow cross-site cookie access. That could be a topic for another post.

In addition, I’ve been playing around with HTML5 canvas, and particularly manipulating images on the fly. I’ve experimented with it before, over the past two years, but until recently it wasn’t supported by enough browsers for me to actually use it for a live project, and in addition the javascript libraries weren’t there yet, so everything had to be hand-coded. jQuery makes things a lot easier, of course. There’s a number of tutorials on the topic now, but I find that they don’t address some of the “obvious” beginner stuff that I had to figure out through trial and error. I may write about this as well, although it will depend on the timing of a project that I can’t talk about yet.

Stay tuned for some techy material!

How to add a custom login box into your Drupal theme

This is a guest post by Nathan, our resident Drupal expert. With luck, it will be the first of a series of posts with a more technical nature than we usually write about here. You can read more of Nathan’s work here: http://bomshteyn.com.

We are starting a new series called Drupal hacks and solutions. This is going to be a useful collection of how-to’s and code examples, based on our experiences.

I am sure every Drupal developer out there has his own ways of styling Drupal (which as http://bomshteyn.com/2010/01/03/should-you-use-wordpress-or-drupal/ discussed is not always an easy task), we are just going to write up the cases that we encountered and solutions we used.

As always there is an easy way to do something and a proper Drupal way of doing the exact same thing. Whenever possible we try to do it the Drupal way, and would advise you to do the same, but i have to admit thats not always the case, and i would sometimes insert a SQL query into a template instead of properly using a drupal function of some sort.

It’s almost a year now since I started working on our first Drupal site; over time I have learned, and continue to learn, new “proper” ways of programming in Drupal and working “with it” versus “around it”.

As you work on a project you have a problem and find a solution, but by the time you get around to the next project and encounter a similar or even same problem (the latest project we were working on was approximately 400 of programming hours) you no longer remember how you solved it last time. In theory you could just open the last project’s code and find the solution, but sometimes its easier said then done, first you have to remember in which project you had this issue and second since an issue in Drupal could be fixed on so many levels (core, theme, modules….), where to look becomes an issue by-itself.

So here we are faced with a case of our own that needs a solution.

Our first urge was to create an internal wiki where we would write down this type of stuff for future use – knowing first hand how hard it is to find an up-to-date solution to some very common problems in theming Drupal. Plus the fact that we always wanted to give back to the open source community of Drupal. We decided to do it as a blog category on our site so that it would be searchable – not just internally but by the whole ever growing Drupal community. As a starting point we will give you an example post, so that you know what to expect.

How to add a custom login box into your Drupal theme

You will probably want to show this only for non logged in users so here is an example of the code you would use:

<?php
if($logged_in){?>
// put some code here
<?php } else {?>
<?php  global $user; ?>
<form action=”<?php print $front_page.’user/login/?’.drupal_get_destination();?>” method=”post” id=”user-login”>
<label for=”edit-name”>username</label>
<input type=”text” name=”name” id=”edit-name” value=”" tabindex=”1″/>
<label for=”edit-pass”>password</label>
<input type=”password” name=”pass” id=”edit-pass” tabindex=”2″/>
<input type=”hidden” name=”form_id” id=”edit-user-login” value=”user_login” />
<input type=”submit” name=”op” id=”edit-submit” tabindex=”3″ value=”Submit” alt=”Submit” />
<p>Forgot <a href=”/user/password”>password</a>? &nbsp; Or <a href=”/user/register”>Create New Account</a></p>
</form>
<?php }?>