Posts Tagged ‘coding standards’

JQuery Tools Library by Flowplayer

jQuery Tools is a collection of the most important user interface components for the web. These are tabs and accordions, tooltips, overlays, exposing effects and scrollables. They can dramatically improve the usability and responsiveness of your site. They mainly focus on presenting information and visual appeal. After all, this is exactly what most websites desperately want: to present their content to the reader in an easy and visually pleasing manner.

Other JavaScript UI libraries focus on desktop-like features such as drag-and-drop, sliders, sortable tables or draggable windows. They are meant to build “rich internet applications” (RIAs) such as email clients, task managers, CRM software, image organizers or feed viewers. These kind of applications are very useful within a small group or when used in intranets; however, normal websites are very different in nature. Their purpose is to look good and present information. jQuery Tools are built exactly for that purpose.

It is recommended that you start designing your pages without using any JavaScript. There are many examples of highly functional, good looking and user friendly web sites that are not using JavaScript. The purpose of this library is to enhance an existing site with the great possibilities that modern JavaScript techniques has to offer. This is essentially the idea of “progressive enhancement” which is a common design pattern today. You should realize that highly professional sites don’t overuse JavaScript just for the fun of it. Scripting is only used when it truly makes the pages more readable and user friendly. This is where these tools comes in to play.

This library is not a framework with a steep learning curve, lots of preliminary work and strict coding rules. You are not tied to any predefined HTML or CSS structures. You can include the library on your pages and start using it immediately. You can freely design the look and feel of your site or you can use the desing we have on our demos as a template.

These tools can be easily combined. Think of scrollables that trigger overlays or overlays that contain scrollables together with tooltips or whatever combination you can imagine. The possibilities are endless. And if that is not enough, you can harness the enormous power of the jQuery library. Many times you see complex JavaScript components implemented that could be done with just a few lines of jQuery code. For many websites, this may be the only JavaScript library necessary.

http://flowplayer.org/tools/using.html

Tools include:

  • tabs
  • tooltip
  • scrollable
  • overlay
  • expose
  • flashembed

PHP Query String Help

Query strings play important role in building web applications, especially if you want to make nice urls without question mark and many key, value pairs, actually it is not so easy to design application with nice urls however it is always worth doing so, because it not only looks very proffessional, such URLs are search engine friendly, which means that they will get indexed faster but also it happens that search engines have problems with indexing pages with more then 3 key=value pairs in query string.

However, one place where using nice URLs is not neccessary are all kinds of admin panels, there are usually only few admins and more over admin panel never gets indexed so it doesn’t make any sense to make those URLs search engine friendly.

Query string can be accessed thru global array $_SERVER, more specific $_SERVER[‘QUERY_STRING’] is the actual variable where query string is written, this variable contains all data that is inputed after question mark in the URL. For example if we have URL which looks like this:
http://someurl.com/page.php?a=1&b=2&c=3

Then echo $_SERVER[‘QUERY_STRING’] will display: a=1&b=2&c=3, such data is no use to us, we need to parse it, or get it thru global array $_GET, in our case we could write:

echo $_GET['a'];
echo $_GET['b'];
echo $_GET['c'];

which would output:

1
2
3

Two things i have to mention here:
– i do not recommend displaying variables passed by user withut checking if they contain potentially dangerous code.
– make sure you have register_globals set to off in your ini file. If you do not have access to ini file, you can change this setting in your .htaccess file (if you have htaccess files working on your server). To do this just add following line php_flag register_globals off.

Using $_GET array to access variables from query string is pretty simple, however we would want to transform our URL to make it look like this:
http://someurl.com/1/2/3
This is very search engine friendly approach, however like always there are no roses without thorns. First problem is that $_SERVER[‘QUERY_STRING’] variable is empty now, so $_GET array is empty as well.

But first thing first, we can’t just input this URL in web browser address bar, hit enter and wait for a page to load. Probably it would end with 404 Error. To avoid this we need to create .htaccess file in the same directory as page.php file. Then open .htaccess file and write in it:

RewriteEngine on
RewriteRule .* page.php

Now all requests to directory which contains file page.php will be redirected to page.php file. Pretty simple and we can now use URL without question mark or any other unwanted signs i provided earlier (e.g. http://someurl.com/1/2/3).

So as i said earlier now our $_GET array is empty, but fortunately we can still check what the URL looks like by writing this code:

echo $_SERVER['REQUEST_URI'];
// output /1/2/3

Well, maybe URL looks pretty search engine friendly however id does not provide a lot of info as it did earlier. Unfortunately solution to this problem is beyond the scope of this article and i will give you only few guidlines: first you need to parse URL wit explode() to get array, then it will be good to assign some keys to each of the variable, but you always need to remember who is who, do not change order of parameters in the URL.

I covered only two types passing arguments to application with query string, there are other solutions as well, but i think that this two are the most common used and are actually the best when it comes to PHP.

PHP and Classic ASP Includes

PHP

<?php include("menu.php"); ?>

Classic ASP

<!--#include virtual="menu.asp"-->