Archive for the ‘Web Design and Development’ Category
Friday, November 7th, 2008
After a few hours work looking into this, this turned out really easy to implement using jQuery and server side PHP programming as follows:
On the client side the following HTML code needs adding to the page:
<form action="/SaveToExcel.php" method="post" target="_blank"
onsubmit='$("#datatodisplay").val( $("<div>").
append( $("#ReportTable").eq(0).clone() ).html() )'>
<input type="image" src="/images/icons/Floppy-48x48.png" width="12" height="12">
<input type="hidden" id="datatodisplay" name="datatodisplay" />
</form>
Note – variables used above – ReportTable is the id of the table you want to save and datatodisplay is a hidden variable used to post the table to the server.
The jQuery commands were added to the form’s onsubmit event but could easily be in your $(function(){}); fuction
The hard part here was getting all of the <table> HTML code. The standard jQuery .html() command gets the innerHTML and was cutting off the <table> HTML code. Getting all the HTML code was accomplished using the code $(“#datatodisplay”).val( $(“<div>”).append( $(“#ReportTable”).eq(0).clone() ).html() ) which effectively gets the outerHTML of the named HTML object (in this case the table we want to save to excel).
On the server side create a file called’SaveToExcel.php’ and add the following code:
<?php
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: filename=export.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<html>
<head></head>
<body><?=$_REQUEST['datatodisplay']?>
</body>
</html>
Posted in Accessibility, jQuery | 12 Comments »
Wednesday, September 24th, 2008
OK so I’ve been talking about PHP errors for a while now but one more post. I found some code for customizing error handing in PHP , I installed it and got overwhelmed with emails reporting errors on my sites. I had to spend most of yesterday fixing issues on my sites. Most were minor issues of course – the worse is using uninitialized variables such as $ret = $Data['notset']; where the value in $Data hasn’t been set. In reality the code works and its being pedantic but it still needs fixing with:
$ret = isset( $Data['notset'] ) ? $Data['notset'] : “” ;
But some reports were real errors, such as unitialised variables that needed a value, referencing arrays using -> instead of [], and other nasties. Some I can do nothing about – WordPress plugins seem to be especially bad for using uninitialised variables. For now I’m using the code on custom applications and avoiding Wordpress.
Posted in Web Design and Development | No Comments »
Wednesday, August 27th, 2008
That’s me, write a program and it works, don’t bother initializing variables, etc. That was until I moved to a new host that had display errors turned off. It is pretty much impossible to debug without errors being displayed so I went rummaging around for ways around this and found the following code:
error_reporting(E_ALL);
ini_set(“display_errors”,1);
I turned this on and suddenly the code was spitting out warnings and messages all over the place. Some trivial but some really fixed issues that I didn’t know. Now I’ve got it turned on all the time in development and on internal systems.
As the ‘Practical PHP Programming’ manual says:
Always set your PHP error level to the most verbose level, E_ALL. All too often people don’t realise that PHP is outputting various complaints about variables not being set, etc, which you can just do away with entirely by cleaning up your code.
Posted in Web Design and Development | 1 Comment »
Tuesday, July 15th, 2008
Following on my theme for this week, here are the steps to make Wordpress mobile friendly. This assumes you are using a separate URL for your mobile friendly wordpress (such as sitename.mobi):
1 – Buy your domain and park it on your current Wordpress site, so sitename.com and sitename.mobi are generating the same content
2 – Add (or modify) the file /wp-content/themes/yourtheme/functions.php and add the following lines:
<?php
remove_action(‘template_redirect’, ‘redirect_canonical’);
function elixir_urlrewrite( $url ) {
if ( strpos( $url, get_bloginfo(“url”,”raw”) ) === false )
return $url ;
$urlparts = parse_url($url) ;
$url = str_replace( $urlparts[scheme] . “://” . $urlparts[host] , “” , $url ) ;
if ( strlen( $url ) == 0 )
$url = “/” ;
return $url ;
}
add_action(‘day_link’, ‘elixir_urlrewrite’);
add_action(‘feed_link’, ‘elixir_urlrewrite’);
add_action(‘month_link’, ‘elixir_urlrewrite’);
add_action(‘page_link’, ‘elixir_urlrewrite’);
add_action(‘post_link’, ‘elixir_urlrewrite’);
add_action(‘the_permalink’, ‘elixir_urlrewrite’);
add_action(‘year_link’, ‘elixir_urlrewrite’);
add_action(‘category_link’, ‘elixir_urlrewrite’);
add_action(‘bloginfo_url’, ‘elixir_urlrewrite’);
?>
This will cause your wordpress installation to rewrite all links to remove sitename.com from them – this stops a mobile visitor always being redirected to the .com site
3 – Modify your .htaccess file and add the following lines (replacing sitename with your site name as applicable):
Options All -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sitename\.com$
RewriteRule ^(.*)$ http://www.sitename.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^sitename\.mobi$
RewriteRule ^(.*)$ http://www.sitename.mobi/$1 [R=301,L]
</IfModule>
This replaces the built in ‘redirect_canonical’ so that it handles .com and .mobi correctly.
4 – modify your template so that it changes the doctype for a mobile device. Modify your header.php fie and replace the current ‘doctype’ line as follows:
<?php
function checkmobile(){
// Always mobile enabled on .mobi
if ( strpos( strtolower( $_SERVER['HTTP_HOST'] ) , “.mobi” ) !== false )
return true ;
if(isset($_SERVER["HTTP_X_WAP_PROFILE"])) return true;
if(preg_match(“/wap\.|\.wap/i”,$_SERVER["HTTP_ACCEPT"])) return true;
if(isset($_SERVER["HTTP_USER_AGENT"])){
$uamatches = array(“midp”, “j2me”, “avantg”, “docomo”, “novarra”, “palmos”, “palmsource”, “240×320″, “opwv”, “chtml”, “pda”, “windows\ ce”, “mmp\/”, “blackberry”, “mib\/”, “symbian”, “wireless”, “nokia”, “hand”, “mobi”, “phone”, “cdm”, “up\.b”, “audio”, “SIE\-”, “SEC\-”, “samsung”, “HTC”, “mot\-”, “mitsu”, “sagem”, “sony”, “alcatel”, “lg”, “eric”, “vx”, “NEC”, “philips”, “mmm”, “xx”, “panasonic”, “sharp”, “wap”, “sch”, “rover”, “pocket”, “benq”, “java”, “pt”, “pg”, “vox”, “amoi”, “bird”, “compal”, “kg”, “voda”, “sany”, “kdd”, “dbt”, “sendo”, “sgh”, “gradi”, “jb”, “\d\d\di”, “moto”);
foreach($uamatches as $uastring){
if(preg_match(“/”.$uastring.”/i”,$_SERVER["HTTP_USER_AGENT"])) return true;
}
}
return false;
}
if ( checkmobile() == true &&
strcmp( strtolower( $_SERVER['HTTP_HOST'] ) , “www.sitename.mobi” ) != 0 &&
strcmp( strtolower( $_SERVER['REQUEST_METHOD'] ) , “get” ) == 0 &&
$_SERVER['SERVER_PORT'] == 80 )
{
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.sitename.mobi” . $_SERVER['REQUEST_URI']);
exit();
}
if ( checkmobile() == true )
{ ?>
<!DOCTYPE html PUBLIC “-//WAPFORUM//DTD XHTML Mobile 1.0//EN” “http://www.openmobilealliance.org/tech/DTD/xhtml-mobile10.dtd“>
<?php
}
else
{ ?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<?php
}
?>
5 – view with a mobile device. This is when you will need to change your CSS and page layout to take into account the limitations of the mobile environment. THis was covered in previous posts:
Making Your Site Mobile Friendly – CSS
To see this in action visit http://www.fionndownhill.mobi/
Posted in Accessibility, Web Design and Development | 9 Comments »
Tuesday, July 8th, 2008
CSS is vitally important in making your site mobile ready. I ended up making 3 CSS media sections in one CSS file:
- @media screen – contains all the CSS positioning informaiton, font sizes needed for the screen, etc.
- @media handheld – the CSS for handhelds. This removed a lot of unneeded parts of the screen (footer text), and doesn’t include positioning information.
- @media print – CSS for when the page is printed. This changes the font size for printing, labels links for printing, turns off unnecessary navigation (left hand menus, footer, etc) and anything else to make your site look good when printed.
All CSS for these sections should be contained within curly brackets {}
@media print{
*{
font-size: 12pt;
font-family:Georgia, "Times New Roman", Times, serif;
}
a{
color: #520;
background: transparent;
font-weight: bold;
text-decoration: underline;
}
}
All of these sections can be in their own CSS files and included using the include syntax:
<style>
@import url("print.css") print;
</style>
or
<LINK rel="stylesheet" type="text/css" media="print" href="print.css">
Posted in Accessibility | 1 Comment »
Thursday, July 3rd, 2008
Setting up CSS for mobile phones is easy enough but what about modifying your site to handle these users. Considering the total people using a mobile phone to surf in a business environment is minimal so you want to minimize the additional webmaster time spent supporting this implementation.
I found this script at http://www.brainhandles.com/2007/10/15/detecting-mobile-browsers/ that detects mobile phones. It’s very simple to implement. I call this script and use it to decide what parts of a page to send to the visitor. For example the top nav on our main site is graphics, by checking the visitor is mobile I output an unordered list of navigation links.
Posted in Accessibility | No Comments »
Friday, December 2nd, 2005
But my Grandmother worried that Amah might be poisoning my mind. “What’s all this hullabaloo about a dead girl?” she complained to my mother.
Now, years later, I have a special place in my heart for Amah. She has long since disappeared from my life—but her ramblings about “Little Sister” have opened my eyes to the possibility that there is more to the universe than meets the eye.
The reality of a universe other than the one we can see and touch has become popular in films and novels. However, we need to go beyond its seduction as pure entertainment and look at its implications as reality.
Quantum mechanics have shown that there is no such thing as a vacuum. What we think of as empty space is actually a vortex of activity, a quantum whirl of particles and waves.
Instead of being reducible to atoms, our world is actually fluid, uncertain. At its most fundamental level, our world is pure energy, pure potential, pure possibility.
What does this mean?
1. Matter can no longer be considered separate and distinct from spirit. And even the insistence we maintain that we are separate bodies and selves is illusory at best. 2.
Space and time exist only in one dimension of our world; there are other dimensions that communicate outside time and space. This means that we can communicate telepathically with someone or something several thousands of miles away. 3. The world is a complex web of interconnecting relationships, a sea of energy that is characterized by its indivisibility. 4. We are part of the
Web. We are the Web. 5. We have the power to influence
external events. Quantum scientists have postulated a particular relationship between the observer and the
observed: the act of observation changes the nature of the observed; in short, what we see is what we get.
Most of us have experienced the Field even though we might not be aware of it.
Have you ever had
- a vivid premonition that came true? – a sense that you are connected to the world, that you are a part of a sea of wholeness? – an effect on something in your environment through intention or desire? – an effect on an object—such as a computer—when you are emotionally charged? – a special connection between you and an animal? – a sense that something that happened to you was eerily co-incidental?
Instead of assigning these occurrences to the realm of the “unusual” or “impossible,” consider this– our “rational”
views of cause and effect, our views that we are separate, individual beings dominated by the passage of time and space are based only on our three-dimensional experience of reality. What if we actually live in a multi-dimensional universe? What if the normal course of events is an unending flow of energy and our insistence on separation and distinction is the perversion that is preventing us from being who and what we really are.
In Feng Shui, everything is done to the environment to facilitate the flow of energy in the house because this flow will have a direct bearing on the flow of energy in the body. Wholeness and Wellness are seen as an uninterrupted flow of power through the body. Illness is a disruption of this flow. And despite my Grandmother’s misgivings, Amah was able to connect me to this flow.
Perhaps we need to rethink our purpose on this earth. Yes life is good and we must live the best we can. Yes, we can work to create the most dynamic relationships and the most profitable businesses. But we can only channel our goals to their ultimate source if we carry this purpose foremost in our hearts—reconnect with the Field, live its energy and teach others to do the same.
Posted in Web Design and Development | No Comments »