Posts tagged: html

New demo system for XMPP-FTW

By , Sunday 10th March 2013 6:39 pm

Originally seen on

I’ve spent most of the day writing a new demo system for XMPP-FTW and despite it looking ugly as sin (I am no god with design) I’m quite pleased with how it works, so I thought I’d write up a little piece about it…

Continue reading 'New demo system for XMPP-FTW'»

Zend Framework: Render If Exists

By , Sunday 12th December 2010 4:19 pm


This is a quick post to discuss the rather simple view helper I created for rendering a Zend Framework style view file only if it exists. Generally asking the code to render a file which doesn’t exist will throw an exception. Therefore I created a wrapper for the Zend_View::render() method which determined whether the file exists and if so renders, otherwise simply returns an empty string.
Continue reading 'Zend Framework: Render If Exists'»

Zend Framework Body Tag View Helper

By , Saturday 21st August 2010 11:13 pm
Photo from

Photo from


Here I discuss the creation of a view helper for modifying HTML tags, and more specifically body tags. The created view helper allows functionality similar to the head*/inlineScript view helpers already in the standard Zend Framework view helpers, but allows the programmatic modification of tag attributes. Definitely check out the demo page and the code on github.


The standard Zend Framework view helpers are a great set of tools for streamlining mundane view tasks and allowing for the modification/addition of scripts and header blocks (generally held in the layout) from within the view without applying ugly hacks (i.e. the head*/inlineScript view helpers).

Upon occasion I have found need to make modifications to the <body> tag, for example adding an onload, class, or style attribute etc. I also required to be able to perform this from within other view helpers. Take this following contrived example…

On website X, certain pages include standard dojo forms. These dojo forms are held within view helpers for convenience. Generally it has been decided not to include the dojo CSS classes in the body tag and only add them when necessary. There maybe several view helpers on the page that need to add their own attributes to the body tag. (I said it was contrived)

The code is available in my GIT repository @ github and the demo page.
Continue reading 'Zend Framework Body Tag View Helper'»

Html Table Generating Class (HtmlTable.php)

By , Tuesday 5th May 2009 9:11 pm

I required to generate a HTML table from PHP data for a project that I was working on. Unfortunately after a bit of Googling I couldn’t really find anything that was suitable so I decided to create my own.

I realise that this may not be the best table generating class ever and there’s probably a few bugs still in it, but I’d prefer to share and if anyone wants a better version I’ll look into it :) I originally wanted to create a table built up of seperate objects e.g. cell object, row object (built up of cell objects), but I realised the overhead on this would be HUGE! So I’ve gone back to an array setup.

The class will calculate the maximum number of columns used in the header, footer, or body and write out that number of columns. Headers, Footers, and the Caption are optional. Attributes are made up of an array where the key is the attribute name and the value is the attribute value. Attributes are applied to table tag (on table creation – class initialisation), table rows (array[row][attribute]), and table cells (array[row][column][attribute]) this applies for headers, footers, and the table body.


I always find the best way to look at something is to use an example so here we go:

$table = new HtmlTable( array('class' =>'sortable',
                'style' => 'width: 550px;'));
$header[0][0]['content'] = 'ID';
$header[0][1]['content'] = 'Title';
$header[0][2]['content'] = 'Date';
$header[0][3]['content'] = 'Site';

$i = 0;
foreach ($newsList AS $newsItem) {
$itemLink = "{$newsItem['title']}";
$tableBody[$i] = array(0 => array('content' => $newsItem['id'],
'attributes' => array('style' => 'font-weight: bold;')),
1 => array('content' => $itemLink),
2 => array('content' => $newsItem['date_posted']),
3 => array('content' => $newsItem['site']) );
echo $table->drawTable();
ID Title Date Site
9 News 1 2009-04-04 10:40:00 site name
10 News 2 2009-04-04 12:44:11 site name

And the HTML looks like this:

<table class = "sortable" style = "width: 550px;" >
	<tr >
		<th >ID</th>
		<th >Title</th>
		<th >Date</th>
		<th >Site</th>
	<tr >
		<td style = "font-weight: bold;" >9</td>
		<td >News 1</td>
		<td >2009-04-04 10:40:00</td>
		<td >site name</td>
	<tr >
		<td style = "font-weight: bold;" >10</td>
		<td >News 2</td>
		<td >2009-04-04 12:40:00</td>
		<td >site name</td>


If you have any comments please make them below, it would be great to hear some. If you end up using it also let me know and I’ll extend it in the future :)

Panorama Theme by Themocracy

6 visitors online now
5 guests, 1 bots, 0 members
Max visitors today: 8 at 07:11 am UTC
This month: 15 at 12-11-2017 04:06 pm UTC
This year: 45 at 02-01-2017 10:28 pm UTC
All time: 130 at 28-03-2011 10:40 pm UTC