www.hutsky.cz / blog / twitter /

Posts Tagged ‘php’

Drag and drop to change position of elements

Wednesday, June 2nd, 2010

Long time ago, I was trying to figure out how to change position of items in a list. Let’s say there’s a list of product in an e-commerce solution and the user wants to choose what items go first and what go last. What I used back then was to create a simple form which called a function that takes the id of the previous or next item and swaps it for the current item’s id and vice versa. It was simple, but it worked. But now I needed something more user-friendly, after all it’s true that this solution was not very convenient for long lists. This is where the motto of jQuery “write less, do more” comes handy.

See demo here.

First, you need a table containing the items:

  1. <table id="positions">
  2.           <tr id="1"><td>item 1</td></tr>
  3.           <tr id="2"><td>item 2</td></tr>
  4.           <tr id="3"><td>item 3</td></tr>
  5.           <tr id="4"><td>item 4</td></tr>
  6.           <tr id="5"><td>item 5</td></tr>
  7.           <tr id="6"><td>item 6</td></tr>
  8. </table>

Now download jQuery and the Table Drag and Drop plugin (if you are new to jQuery, there’s great documentation on their page).

Having installed jQuery file and the TableDnD plugin, we need to get things working. Include this in the head section of the website:

(more…)

Kohana php framework – part 1.

Tuesday, January 26th, 2010

Just like most people, I like working on projects that are exceptional and require an innovative approach, but just like with most other jobs, the greater part of my work tends to be repetitive (and one cannot allow himself the luxury of turning such projects down). A framework is supposed to make this repetitive work a great deal easier. But when building a simple website such as this one , there’s no actual need for a sophisticated framework. The bigger projects, where a framework could have been useful, were always to be tailored to the client’s individual needs so I deemed it wiser to stick to clean php code; and beyond that the deadlines were usually so deadly that there was no space for trying out anything new. (more…)

Maintaining mobile web content

Friday, January 15th, 2010

This post is no official guideline but rather a log of steps I’m taking after having decided to build my sites in a more mobile device friendly way and a compilation of sources generally available on the net (most links included).

Why serve mobile content?

Mobile web content. The big question for me was why bother at all? Optimizing websites for mobiles means extra costs and few of my clients even know it’s possible, so I’ve never faced a demand to consider any of my projects from the mobile point of view nor was I particularly worried about this issue myself.

This changed when I bought my first handheld device and discovered that with the exception of big players like BBC or Google, it was often frustrating to browse most of the regular websites out there. Naturally, I turned to my own websites to see how they were standing. Luckily for me, it’d always been my opinion that a website should be kept as simple as possible, using JS only as a supplementary feature and avoiding flash completely if possible, so I was glad to find out that I was able to view and navigate the bigger part of my websites. However, lots of things were pretty bad – above all the size of the page. (more…)