<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>James Tombs</title>
	
	<link>http://jamestombs.co.uk</link>
	<description>Development blog from James Tombs about PHP, XHTML + CSS, Drupal and Wordpress</description>
	<lastBuildDate>Fri, 25 Sep 2009 14:03:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/JamesTombs" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Using jQuery Flot for Drupal reporting</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/a1uaUJS_CrI/1062</link>
		<comments>http://jamestombs.co.uk/2009-09-25/using-jquery-flot-for-drupal-reporting/1062#comments</comments>
		<pubDate>Fri, 25 Sep 2009 14:03:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[admin reports]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[flot]]></category>
		<category><![CDATA[graphical plots]]></category>
		<category><![CDATA[javascript function]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1062</guid>
		<description><![CDATA[Flot is a pure Javascript plotting library for jQuery. It produces graphical plots of arbitrary datasets on-the-fly client-side. 
In this tutorial I will show you how to use Flot to create a graph which shows how many nodes have been created over a certain date range and how to seperate these by node type. The [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><a href="http://code.google.com/p/flot/">Flot</a> is a pure Javascript plotting library for <a href="http://jquery.com/">jQuery</a>. It produces graphical plots of arbitrary datasets on-the-fly client-side. </p></blockquote>
<p>In this tutorial I will show you how to use Flot to create a graph which shows how many nodes have been created over a certain date range and how to seperate these by node type. The tutorial uses Drupal 6 but the prinicpal is the same for Drupal 5, you will just need to change the hook_menu reference.</p>
<h2>Download Flot</h2>
<p>Before we can start using <a href="http://code.google.com/p/flot/downloads/list">Flot</a>, we need to download the files. </p>
<p>Download either the .zip or .tar.gz from <a href="http://code.google.com/p/flot/downloads/list">http://code.google.com/p/flot/downloads/list</a>.</p>
<h2>Create a module</h2>
<p>We will create a custom module which will create a menu item under reports and set it up so only certain roles have access to the graph.</p>
<p>Create a folder in your sites/all/modules folder and call it whatever you want, I will call mine myflot.</p>
<p>Create a folder within your module folder and name it <strong>js</strong>. In this folder place the file called <strong>jquery.flot.pack.js</strong> which is located in the zip/tar.gz that you downloaded from the Flot website.</p>
<p>In this folder create a file called <strong>&lt;modulename&gt;.info</strong> and insert the following:</p>
<pre>
name = My Flot
description = Helps with minor modifications to Drupal workings
core = 6.x
</pre>
<p>Then create a file called <strong>&lt;modulename&gt;.module</strong> and enter the following code, changing wherever it says myflot to the name of your module. The code is fully commented.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Create a new permission for viewing the graph.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> myflot_perm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'access flot graph'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Create a menu entry to access the graph.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> myflot_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$items</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'admin/reports/flot'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Node creation graph'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'page callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'myflot_display_graph'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'access callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'user_access'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'access arguments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'access flot graph'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$items</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Create the graph and add the javascript.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> myflot_display_graph<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timechange</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Set some date ranges for users to select how many days to view.</span>
  <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-1 day'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-2 days'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-3 days'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-4 days'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-5 days'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-6 days'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-1 week'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-2 weeks'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-3 weeks'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-4 weeks'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-2 months'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$links</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> l<span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'admin/reports/flot/'</span><span style="color: #339933;">.</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// Place the links inside a collapsed fieldset.</span>
  <span style="color: #000088;">$fieldset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'#title'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Date select'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'#collapsible'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'#collapsed'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'#value'</span> <span style="color: #339933;">=&gt;</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'item_list'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$links</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fieldset'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fieldset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Add the Javascript file for Flot.</span>
  drupal_add_js<span style="color: #009900;">&#40;</span>drupal_get_path<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'module'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'myflot'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'/js/jquery.flot.pack.js'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'module'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'header'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// We set the amount of time to look back on if the time isn't already set.</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$timechange</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$timechange</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-2 weeks'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timechange</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$last</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$iter8</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$start</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$dates</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// The first thing we do is create an array with a value of 0 for every day from the start to the end date. This is to make sure there is data set for every day, otherwise you will get an inaccurate graph.</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$iter8</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$last</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> myflot_unix<span style="color: #009900;">&#40;</span><span style="color: #000088;">$iter8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$dates</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$key</span>&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$iter8</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$iter8</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' +1 day'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// We get a list of all the node types that have nodes already created and published.</span>
  <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT DISTINCT n.type FROM {node} n WHERE n.status = <span style="color: #009933; font-weight: bold;">%d</span>&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> db_query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$node_types</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> db_fetch_object<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$node_types</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// We set up a variable to contain the hightest number of nodes created for a node type, this way we can extend the graph up a bit.</span>
  <span style="color: #000088;">$maxcount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Cycle through each node type, counting how many nodes were created of that type grouped by the date created.</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$node_types</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$node_type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$node_data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$node_type</span>&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dates</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT COUNT(1) as count, FROM_UNIXTIME(n.created, '<span style="color: #009933; font-weight: bold;">%%</span>Y-<span style="color: #009933; font-weight: bold;">%%</span>m-<span style="color: #009933; font-weight: bold;">%%</span>d') as time FROM {node} n WHERE n.type = '<span style="color: #009933; font-weight: bold;">%s</span>' AND n.status = <span style="color: #009933; font-weight: bold;">%d</span> AND n.created &gt; <span style="color: #009933; font-weight: bold;">%d</span> GROUP BY FROM_UNIXTIME(n.created, '<span style="color: #009933; font-weight: bold;">%%</span>Y-<span style="color: #009933; font-weight: bold;">%%</span>m-<span style="color: #009933; font-weight: bold;">%%</span>d') ORDER BY n.created ASC&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> db_query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node_type</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> myflot_unix<span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> db_fetch_object<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// If the count is higher than the existing highest count, we increase the maxcount variable.</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$maxcount</span><span style="color: #009900;">&#41;</span>  <span style="color: #000088;">$maxcount</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">// We set the key to the Unix timestamp in UTC that Flot requires.</span>
      <span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> myflot_unix<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">// Update the array with the count.</span>
      <span style="color: #000088;">$node_data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$node_type</span>&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$key</span>&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// Now we have all the data we need in an array, we need to get it set up for the Javascript. You can find out more about this in the Flot API documentation.</span>
  <span style="color: #000088;">$flot</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$node_data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$label</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$js_data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$vals</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$js_data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$time</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$count</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$vals</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'['</span><span style="color: #339933;">.</span> <span style="color: #000088;">$time</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">']'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$flot</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'{ label: &quot;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$label</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;, data: ['</span><span style="color: #339933;">.</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$vals</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'] }'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000088;">$flot</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$flot</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// We increase the maxcount by 2 to increase the y-axis by 2 values so the top value doesn't hit the top.</span>
  <span style="color: #000088;">$maxcount</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Now we add in the data to the graph and plot it.</span>
  drupal_add_js<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$(document).ready(function() {
    var datasets = ['</span><span style="color: #339933;">.</span> <span style="color: #000088;">$flot</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'];
&nbsp;
    // This makes sure the colour stays the same whether we deselect the node type from the graph.
    var i = 0;
    $.each(datasets, function(key, val) {
      val.color = i;
      ++i;
    });
&nbsp;
  // Define the function to show the tooltips when the mouse cursor is placed over a point on the graph.
  function showTooltip(x, y, contents) {
    $(&quot;&lt;div id=\&quot;tooltip\&quot;&gt;&quot; + contents + &quot;&lt;/div&gt;&quot;).css({
      position: &quot;absolute&quot;,
      display: &quot;none&quot;,
      top: y - 30,
      left: x + 15,
      border: &quot;1px solid #ddd&quot;,
      padding: &quot;3px&quot;,
      &quot;background-color&quot;: &quot;#f7f7f7&quot;,
      opacity: 0.90
    }).appendTo(&quot;body&quot;).fadeIn(200);
  }
&nbsp;
  // A function to convert the timestamp used by Flot to a readable date format for humans.
  function showLocalDate(timestamp) {
    var newDate = new Date();
    newDate.setTime(timestamp);
    return newDate.toGMTString();
  }
&nbsp;
  // Set up the checkbox inputs to select and deselect node types from appearing on the graph. You can add in some extra HTML if you wish to add more control to the styling.
  var choiceContainer = $(&quot;#choices&quot;);
  $.each(datasets, function(key, val) {
    choiceContainer.append(&quot;&lt;div class=\&quot;choice\&quot;&gt;&lt;input type=\&quot;checkbox\&quot; name=\&quot;&quot; + key + &quot;\&quot; checked=\&quot;checked\&quot;&gt;&quot; + val.label + &quot;&lt;/input&gt;&lt;/div&gt;&quot;);
  });
  // When one of the checkboxes is click, update the graph.
  choiceContainer.find(&quot;input&quot;).click(plotAccordingToChoices);
&nbsp;
  function plotAccordingToChoices() {
    // Start off with an empty array for our data.
    var data = [];
    // Select the checkboxes that are ticked and get the data out of the dataset variable and put in to the data variable defined above.
    choiceContainer.find(&quot;input:checked&quot;).each(function () {
      var key = $(this).attr(&quot;name&quot;);
      if (key &amp;&amp; datasets[key])
        data.push(datasets[key]);
    });
    // Here we can set options for the graph.  For the x-axis we define it as &quot;time&quot; so that the dates appear rather than the Unix timestamp. For the y-axis we set the maximum value.
    var options = {
      xaxis: { mode: &quot;time&quot; },
      yaxis: { max: '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$maxcount</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">', tickDecimals: 0 },
      grid: { hoverable: true },  // We set hoverable to true to allow the tooltips
      legend: { noColumns: 4, container: $(&quot;#flot-legend&quot;) } // Create a legend so the user can easily see which series response to which colour.  We also set the container so it does not cover the graph.
    };
    // Create the graph
    $.plot($(&quot;#graph&quot;), data, options);
&nbsp;
    // Set up the tooltips on each point for when the user hovers the mouse over it.
    var previousPoint = null;
    $(&quot;#graph&quot;).bind(&quot;plothover&quot;, function (event, pos, item) {
      $(&quot;#x&quot;).text(pos.x.toFixed(2));
      $(&quot;#y&quot;).text(pos.y.toFixed(2));
      if (item) {
        if (previousPoint != item.datapoint) {
          previousPoint = item.datapoint;
          $(&quot;#tooltip&quot;).remove();
          var x = item.datapoint[0].toFixed(2),
               y = item.datapoint[1].toFixed(2);
          // Here you can set the text that appears in the tooltip.
          showTooltip(item.pageX, item.pageY, &quot;&lt;strong&gt;Nodes:&lt;/strong&gt; &quot; + Math.round(y) + &quot;&lt;br /&gt;&lt;strong&gt;Date&lt;/strong&gt; &quot; + showLocalDate(x) + &quot;&lt;br /&gt;&lt;strong&gt;Node type:&lt;/strong&gt; &quot; + item.series.label);
        }
      }
      else {
        $(&quot;#tooltip&quot;).remove();
        previousPoint = null;            
      }
    });	
  }
  // When the page loads, initiate the graph.
  plotAccordingToChoices();
  })'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'inline'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'footer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// We need to set out the placeholders for our graph, legend and checkboxes.</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;div id=&quot;graph&quot; style=&quot;width:650px;height:480px;&quot;&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;div id=&quot;flot-legend&quot; style=&quot;margin-top:10px;width:650px;&quot;&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;div id=&quot;choices&quot; style=&quot;margin-bottom: 10px;&quot;&gt;&lt;h3&gt;Show/hide node types&lt;/h3&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Convert a date in the format Y-m-d to a Unix timestamp.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> myflot_unix<span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #339933;">,</span> <span style="color: #000088;">$utc</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$year</span><span style="color: #339933;">,</span> <span style="color: #000088;">$month</span><span style="color: #339933;">,</span> <span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$month</span><span style="color: #339933;">,</span> <span style="color: #000088;">$day</span><span style="color: #339933;">,</span> <span style="color: #000088;">$year</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$utc</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$time</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$time</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>For more information check out the <a href="http://people.iola.dk/olau/flot/API.txt">Flot API documentation</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/oFJ3gpVvhIX3HPjPLKkmLkBRTsM/0/da"><img src="http://feedads.g.doubleclick.net/~a/oFJ3gpVvhIX3HPjPLKkmLkBRTsM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oFJ3gpVvhIX3HPjPLKkmLkBRTsM/1/da"><img src="http://feedads.g.doubleclick.net/~a/oFJ3gpVvhIX3HPjPLKkmLkBRTsM/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-09-25/using-jquery-flot-for-drupal-reporting/1062/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-09-25/using-jquery-flot-for-drupal-reporting/1062</feedburner:origLink></item>
		<item>
		<title>780G chipset sound output through HDMI</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/ee9ZolfWd2I/1055</link>
		<comments>http://jamestombs.co.uk/2009-07-21/780g-chipset-sound-output-through-hdmi/1055#comments</comments>
		<pubDate>Tue, 21 Jul 2009 12:29:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PCs]]></category>
		<category><![CDATA[5.1]]></category>
		<category><![CDATA[dts]]></category>
		<category><![CDATA[htpc]]></category>
		<category><![CDATA[onboard sound]]></category>
		<category><![CDATA[playback device]]></category>
		<category><![CDATA[realtek driver]]></category>
		<category><![CDATA[sony str]]></category>
		<category><![CDATA[stereo sound]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1055</guid>
		<description><![CDATA[I had a few issues with my HTPC where the sound only came out as stereo on my Sony STR-KS1300.
All drivers were installed correctly and the onboard sound was disabled.
But when viewing the supported formats for the playback device, it only listed 2 channels.  Unfortunately I have been unable to change this, although I [...]]]></description>
			<content:encoded><![CDATA[<p>I had a few issues with <a href="http://jamestombs.co.uk/2009-07-20/htpc-resetup-using-windows-7-and-mce/1054">my HTPC</a> where the sound only came out as stereo on my <a href="http://www.sony.co.uk/product/hcs-cinema-surround-kit/ht-ss1300/tab/technicalspecs">Sony STR-KS1300</a>.</p>
<p>All drivers were installed correctly and the onboard sound was disabled.</p>
<p><a href="http://www.amazon.co.uk/HDMI-Cable-KING-Plated-Ferrite/dp/B001R660DM%3FSubscriptionId%3D02E5W5871AJF7PMMMS82%26tag%3Djamestombs-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001R660DM" style="float: left; padding: 0 10px 10px 0;"><img src="http://ecx.images-amazon.com/images/I/31JbN6pgIWL._SL75_.jpg" /></a>But when viewing the supported formats for the playback device, it only listed 2 channels.  Unfortunately I have been unable to change this, although I have got full 5.1 DTS and DD sound coming through to the receiver, by selecting S/PDIF pass-through in all the applications (even through I was using HDMI, not optical).  The only problem with this is music comes through stereo only as WMP doesn&#8217;t pass-through stereo sound through as 5.1 in anyway and foobar doesn&#8217;t support pass-through, although there is a component you can download, but this wouldn&#8217;t work for my sound card as I think the DVD-A disc rips are 6 channel rather than 2.</p>
<p>I think the only way of getting proper 5.1 surround sound out of music, will be to buy another sound card and use another audio input in to the receiver.</p>
<p>Driver wise, I used the latest <a href="http://support.amd.com/us/gpudownload/Pages/index.aspx">Catalyst package</a> (9.6) and the <a href="http://www.realtek.com.tw/DOWNLOADS/downloadsView.aspx?Langid=1&#038;PNid=24&#038;PFid=24&#038;Level=4&#038;Conn=3&#038;DownTypeID=3&#038;GetDown=false">Realtek ATi HDMI Audio driver</a> (2.28).  At this point I would also like to point out that the download speed from Realtek is diabolical.  I ended up getting the filename of the file and searching on Google to find a mirror.  Don&#8217;t be fooled by the other driver download sites, as they just directly link to the Realtek driver rather than a proper mirror.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/FY3Whbc3mMg1nPKJLP8Zbuob2Zg/0/da"><img src="http://feedads.g.doubleclick.net/~a/FY3Whbc3mMg1nPKJLP8Zbuob2Zg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/FY3Whbc3mMg1nPKJLP8Zbuob2Zg/1/da"><img src="http://feedads.g.doubleclick.net/~a/FY3Whbc3mMg1nPKJLP8Zbuob2Zg/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-07-21/780g-chipset-sound-output-through-hdmi/1055/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-07-21/780g-chipset-sound-output-through-hdmi/1055</feedburner:origLink></item>
		<item>
		<title>HTPC resetup using Windows 7 and MCE</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/TJGSJ8QfRiI/1054</link>
		<comments>http://jamestombs.co.uk/2009-07-20/htpc-resetup-using-windows-7-and-mce/1054#comments</comments>
		<pubDate>Mon, 20 Jul 2009 12:05:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PCs]]></category>
		<category><![CDATA[file server]]></category>
		<category><![CDATA[home server]]></category>
		<category><![CDATA[htpc]]></category>
		<category><![CDATA[mediaportal]]></category>
		<category><![CDATA[meta data]]></category>
		<category><![CDATA[windows media centre]]></category>
		<category><![CDATA[wmc]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1054</guid>
		<description><![CDATA[From my previous post about building my HTPC and configuring the HTPC using MediaPortal, I have now changed my setup software wise.
Server
Before with MediaPortal I was able to set up multiple shares on a file server running Windows Vista.  This has now been changed to running Windows Home Server.  The initial steps to [...]]]></description>
			<content:encoded><![CDATA[<p>From my previous post about <a href="http://jamestombs.co.uk/2008-10-26/built-my-first-htpc-home-theatre-personal-computer/938">building my HTPC</a> and <a href="http://jamestombs.co.uk/2008-12-11/htpc-software-configuration-using-mediaportal/955">configuring the HTPC using MediaPortal</a>, I have now changed my setup software wise.</p>
<h2>Server</h2>
<p>Before with MediaPortal I was able to set up multiple shares on a file server running Windows Vista.  This has now been changed to running Windows Home Server.  The initial steps to install WHS (Windows Home Server) were not as straight forward as I initially planned as installation requires all connected drives to be wiped.  So I unplugged the 2 1TB data drives leaving the 500GB OS drive to be formatted.  Installation of WHS was easy, as it normally is with Windows. I have no CD/DVD drive in my file server, so I had to resort to creating a bootable USB stick with the WHS CD files on it.  This installed without problem.</p>
<p>Once WHS was up and running, it is just a matter of plugging a new hard drive in and WHS adds it to the array.  Unfortunately this wipes all the data from the disk, so I had to connect them to another computer, copy the data to the computer, connect the drive to the file server, then add the drive to the array, then move the files from the other computer to the file server.</p>
<p>This was time consuming but worth it.  I now have a 4TB array with lots of DVD backups as well as music and a backup of personal documents, which can be recovered if there is a problem with the other computers in the house.</p>
<h2>HTPC configuration</h2>
<p>First step was to reformat the HTPC and install Windows 7 RC.  This went smoothly and works pretty much as expected.  The only problem being the sound, but I will get on to that in another post.</p>
<p>I chose to use Windows Media Centre as the UI rather than MediaPortal this time as it has better support for a remote in the future which means I can hide the keyboard and mouse.</p>
<p>Using WMC provides a few problems.</p>
<ul>
<li>Metadata</li>
<li>Thumbnails/Images</li>
<li>MKV/Avi support</li>
</ul>
<h3>Metadata</h3>
<p>To get the meta data for my films, I used <a href="http://themetabrowser.com/"><meta>browser</a>.  This is a great bit of software that allows you to get the synopsis as well as actors/genre/director(s) of each film as well as a smaller thumbnail and a large image to be used as a backdrop.  It has full support for TV shows as long as you store all your videos in the right folder structure.</p>
<h3>Thumbnails/Images</h3>
<p>I opted for <a href="http://www.mediabrowser.tv/">MediaBrowser</a> which plugs straight in to WMC creating a new entry on the main navigation.  MediaBrowser is currently free but looks to be becoming a commercial product on a yearly licence, but assuming it continues to improve, it should be worth it.</p>
<h3>MKV/Avi support</h3>
<p>I initially looked at passing on MKV files on to an external player which you can do within MediaBrowser, but in the end chose to use the <a href="http://shark007.net/">Shark 007 codec pack</a> which allows WMC to play MKV H264 files perfectly, with the ability to rewind/fastforward pause etc within WMC.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/xERhkMhFm0-YZmeyIQmv6otw-SY/0/da"><img src="http://feedads.g.doubleclick.net/~a/xERhkMhFm0-YZmeyIQmv6otw-SY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/xERhkMhFm0-YZmeyIQmv6otw-SY/1/da"><img src="http://feedads.g.doubleclick.net/~a/xERhkMhFm0-YZmeyIQmv6otw-SY/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-07-20/htpc-resetup-using-windows-7-and-mce/1054/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-07-20/htpc-resetup-using-windows-7-and-mce/1054</feedburner:origLink></item>
		<item>
		<title>[Drupal] An error occured while attempting to process add Content Modal form</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/2dy-CisvBTg/1053</link>
		<comments>http://jamestombs.co.uk/2009-07-16/drupal-an-error-occured-while-attempting-to-process-add-content-modal-form/1053#comments</comments>
		<pubDate>Thu, 16 Jul 2009 10:21:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1053</guid>
		<description><![CDATA[When trying to add some content new a pane in Panels in Drupal 5 you may get this message.
In my case it was caused by the Secure Pages module.  To fix this add the following line to your Secure Pages configuration under Ignore pages:
*ajax*
]]></description>
			<content:encoded><![CDATA[<p>When trying to add some content new a pane in <a href="http://drupal.org/project/panels">Panels</a> in <a href="http://drupal.org/project/drupal">Drupal 5</a> you may get this message.</p>
<p>In my case it was caused by the <a href="http://drupal.org/project/securepages">Secure Pages</a> module.  To fix this add the following line to your <a href="http://drupal.org/project/securepages">Secure Pages</a> configuration under Ignore pages:</p>
<p><code>*ajax*</code></p>

<p><a href="http://feedads.g.doubleclick.net/~a/vvEUHe8qLfnQCQ3tm-yNGKd_Zdw/0/da"><img src="http://feedads.g.doubleclick.net/~a/vvEUHe8qLfnQCQ3tm-yNGKd_Zdw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vvEUHe8qLfnQCQ3tm-yNGKd_Zdw/1/da"><img src="http://feedads.g.doubleclick.net/~a/vvEUHe8qLfnQCQ3tm-yNGKd_Zdw/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-07-16/drupal-an-error-occured-while-attempting-to-process-add-content-modal-form/1053/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-07-16/drupal-an-error-occured-while-attempting-to-process-add-content-modal-form/1053</feedburner:origLink></item>
		<item>
		<title>No add button in IMCE in Drupal when using the Secure Pages module</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/PahIzzWDhpA/1052</link>
		<comments>http://jamestombs.co.uk/2009-07-06/no-add-button-in-imce-in-drupal-when-using-the-secure-pages-module/1052#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:46:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[imce]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1052</guid>
		<description><![CDATA[There may be cases where you are using IMCE with Drupal and have the IMCE appear on node add/edit pages which use a secure URL.  You need to add the following to the ignore section of the Secure Pages module.
imce*
Go back to your node add/edit page and you should now have the add button [...]]]></description>
			<content:encoded><![CDATA[<p>There may be cases where you are using IMCE with Drupal and have the IMCE appear on node add/edit pages which use a secure URL.  You need to add the following to the ignore section of the Secure Pages module.</p>
<p><code>imce*</code></p>
<p>Go back to your node add/edit page and you should now have the add button in IMCE.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/kwMYkQcA0XMpEcEq87OpplcooYM/0/da"><img src="http://feedads.g.doubleclick.net/~a/kwMYkQcA0XMpEcEq87OpplcooYM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/kwMYkQcA0XMpEcEq87OpplcooYM/1/da"><img src="http://feedads.g.doubleclick.net/~a/kwMYkQcA0XMpEcEq87OpplcooYM/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-07-06/no-add-button-in-imce-in-drupal-when-using-the-secure-pages-module/1052/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-07-06/no-add-button-in-imce-in-drupal-when-using-the-secure-pages-module/1052</feedburner:origLink></item>
		<item>
		<title>Firefox 3.5 released – No sign of Yslow or Google Gears</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/ngtlxKg8Xuk/1051</link>
		<comments>http://jamestombs.co.uk/2009-07-02/firefox-3-5-released-no-sign-of-yslow-or-google-gears/1051#comments</comments>
		<pubDate>Thu, 02 Jul 2009 12:35:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google gears]]></category>
		<category><![CDATA[page speed]]></category>
		<category><![CDATA[web developer]]></category>
		<category><![CDATA[yslow]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1051</guid>
		<description><![CDATA[Firefox 3.5 is now available for download and a highly used addon by most developers hasn&#8217;t been updated.
Yslow has yet to be updated, neither has CSSViewer.  The Web Developer Toolbar and Firebug are both up to date though.
Google Gears is also not available yet, but Google has released another addon for Firefox called Page [...]]]></description>
			<content:encoded><![CDATA[<p>Firefox 3.5 is now available for <a href="http://www.mozilla-europe.org/en/firefox/">download</a> and a highly used addon by most developers hasn&#8217;t been updated.</p>
<p>Yslow has yet to be updated, neither has CSSViewer.  The <a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer Toolbar</a> and <a href="http://getfirebug.com/">Firebug</a> are both up to date though.</p>
<p><a href="http://gears.google.com/">Google Gears</a> is also not available yet, but Google has released another addon for Firefox called <a href="http://code.google.com/speed/page-speed/index.html">Page Speed</a>. Page Speed, much like Yslow, is used to evaluate the performance of webpages as well as giving suggestions on how to improve the performance.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/B8ZgkwB2zZvDXk24ZJFbDluaF80/0/da"><img src="http://feedads.g.doubleclick.net/~a/B8ZgkwB2zZvDXk24ZJFbDluaF80/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/B8ZgkwB2zZvDXk24ZJFbDluaF80/1/da"><img src="http://feedads.g.doubleclick.net/~a/B8ZgkwB2zZvDXk24ZJFbDluaF80/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-07-02/firefox-3-5-released-no-sign-of-yslow-or-google-gears/1051/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-07-02/firefox-3-5-released-no-sign-of-yslow-or-google-gears/1051</feedburner:origLink></item>
		<item>
		<title>Add a publish button on node edit forms in Drupal 6 using a custom module</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/_gFCjg6V1xA/1050</link>
		<comments>http://jamestombs.co.uk/2009-06-25/add-a-publish-button-on-node-edit-forms-in-drupal-6-using-a-custom-module/1050#comments</comments>
		<pubDate>Thu, 25 Jun 2009 13:14:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1050</guid>
		<description><![CDATA[This tutorial assumes you have a reasonable knowledge of Drupal such as being able to create a custom module. It also requires an understanding of PHP and jQuery.
Create a new module, I will call mine node_publish.
The first thing I will do is create a callback function that will be used to publish the node.  [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial assumes you have a reasonable knowledge of Drupal such as being able to create a custom module. It also requires an understanding of PHP and jQuery.</p>
<p>Create a new module, I will call mine node_publish.</p>
<p>The first thing I will do is create a callback function that will be used to publish the node.  To do this, I will first create a menu item using hook_menu().</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> node_publish_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$items</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'node/%/publish'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Node published'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'page callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'node_publish_publish'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'page arguments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'access arguments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'administer nodes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> MENU_CALLBACK<span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$items</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This uses the menu path of node/<nid>/publish, much the same way that node/<nid>/delete and node/<nid>/edit work. This will call the function node_publish_publish.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> node_publish_publish<span style="color: #009900;">&#40;</span><span style="color: #000088;">$nid</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nid</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    db_query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE {node} SET status = 1 WHERE nid = <span style="color: #009933; font-weight: bold;">%d</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'destination'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    drupal_goto<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'destination'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    drupal_goto<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'node/'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$nid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This function takes the nid out of the path and checks to make sure it is numeric, if it is we set the status to published for that node.</p>
<p>Once the node is published, we will redirect the user to another page.  In this case I have looked to see if a destination is already set, if so go to it, otherwise return to the node view.</p>
<p>Now you can create a link to node/<nid>/publish in any of your other modules or views which will publish the node.  But this tutorial is going to expand to adding a button on to the node edit form to allow you to publish, rather than having to check the Published box then press Submit.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> node_publish_form_alter<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$form</span><span style="color: #339933;">,</span> <span style="color: #000088;">$form_state</span><span style="color: #339933;">,</span> <span style="color: #000088;">$form_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$base_url</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_node_form'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nid'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'#value'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'options'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'status'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'#default_value'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>user_access<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'administer nodes'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$form</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'buttons'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'publish'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'#type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'button'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'#value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Publish'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'#submit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'#attributes'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
          <span style="color: #0000ff;">'onclick'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'return false;'</span><span style="color: #339933;">,</span>
          <span style="color: #0000ff;">'style'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'display:none;'</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      drupal_add_js<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$(document).ready(function() {
        $(&quot;#edit-publish&quot;).show();
        $(&quot;#edit-publish&quot;).click(function() {
          window.location = &quot;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$base_url</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'/node/'</span><span style="color: #339933;">.</span> arg<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'/publish&quot;;
          return false;
        });
      });'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'inline'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'footer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The above should be self explanatory to most people, but for those that it isn&#8217;t:</p>
<p>First we get the data for the $user object and the $base_url of the site.  Then we check to make sure the form_id ends with _node_form as this will cover all nodes.  We then make sure that the $form array doesn&#8217;t have an empty nid value, if it does then the form is for a new node and shouldn&#8217;t feature the publish button.  We then check to make sure that the node isn&#8217;t already published, if it is there is no point in showing the publish button.</p>
<p>We then perform a check to make sure the user has access to publish nodes. If they have then we add in a simple button with an onclick attribute of return false, which will stop it acting like a submit button for users with javascript.  For users without javascript the style attribute will remove the button from view allowing the user to use the checkbox and press submit.</p>
<p>The jQuery that we have firsts shows the button, as it is hidden by default, then set up a click function for the button.  We direct the user to the publish page which will then take them to the node view.  Alternatively you can modify the jQuery to do a POST action and publish the node in the background and also check the published box allowing further modification of the node.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/M2oTTLKAZ-3tRCDbKOZO_0efyj4/0/da"><img src="http://feedads.g.doubleclick.net/~a/M2oTTLKAZ-3tRCDbKOZO_0efyj4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/M2oTTLKAZ-3tRCDbKOZO_0efyj4/1/da"><img src="http://feedads.g.doubleclick.net/~a/M2oTTLKAZ-3tRCDbKOZO_0efyj4/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-06-25/add-a-publish-button-on-node-edit-forms-in-drupal-6-using-a-custom-module/1050/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-06-25/add-a-publish-button-on-node-edit-forms-in-drupal-6-using-a-custom-module/1050</feedburner:origLink></item>
		<item>
		<title>Creating a grid of images for an album in Drupal 6</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/E6epkGD4Dv8/1046</link>
		<comments>http://jamestombs.co.uk/2009-06-25/creating-a-grid-of-images-for-an-album-in-drupal/1046#comments</comments>
		<pubDate>Thu, 25 Jun 2009 09:53:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[album]]></category>
		<category><![CDATA[albums]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[displayed]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/?p=1046</guid>
		<description><![CDATA[Following on from the tutorial of creating an album based gallery in Drupal 6. This tutorial will teach you how to create a basic grid of the images in the node.
In your content type, go to Display fields and set the Full node to &#60;Hidden&#62;. This will take the images out of the $content variable.
Then [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from the tutorial of <a href="http://jamestombs.co.uk/2009-05-12/create-an-album-based-image-gallery-in-drupal-6-using-cck-and-views/1045">creating an album based gallery in Drupal 6</a>. This tutorial will teach you how to create a basic grid of the images in the node.</p>
<p>In your content type, go to Display fields and set the Full node to &lt;Hidden&gt;. This will take the images out of the <strong>$content</strong> variable.</p>
<p>Then in your theme, copy the existing node.tpl.php and create a new identical file called node-album.tpl.php (the album part with be the content type name that you used from the tutorial.)</p>
<p>Below the content section, add the following PHP code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$images</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">field_images</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
  <span style="color: #000088;">$rows</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$images_per_row</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$rows</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;a class=&quot;gallery-thumbs&quot; title=&quot;'</span><span style="color: #339933;">.</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; rel=&quot;lightbox[photo_gallery-'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nid</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">']&quot; href=&quot;'</span><span style="color: #339933;">.</span> imagecache_create_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'lightbox'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filepath'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'imagecache'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filepath'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span> ? <span style="color: #0000ff;">'&lt;br /&gt;&lt;small&gt;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'data'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/small&gt;&lt;/a&gt;'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$images_per_row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$row</span><span style="color: #339933;">++;</span>
      <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;table class=&quot;views-view-grid&quot;&gt;
  &lt;tbody&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rows</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$row_number</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$columns</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      <span style="color: #000000; font-weight: bold;">&lt;?php</span>
        <span style="color: #000088;">$row_class</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'row-'</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row_number</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row_number</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$row_class</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' row-first'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rows</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row_number</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$row_class</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' row-last'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;tr class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$row_class</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$columns</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$column_number</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          &lt;td class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'col-'</span><span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_number</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$item</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          &lt;/td&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;/tr&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;/tbody&gt;
&lt;/table&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;p&gt;No images in album&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The table code is a direct copy from views-view-grid.tpl.php so the code should look identical to the Album view.</p>
<p>Replace the following with your own settings:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">imagecache_create_url<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'lightbox'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filepath'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Change lightbox for the name of the imagecache preset that should open up within the lightbox.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'imagecache'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filepath'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Change thumbnail to the name of the imagecache preset that should be displayed.</p>
<p>To add more columns to your grid, change the <strong>$images_per_row</strong> variable.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/AYux5d5cdCsYD4wwigWLwkETe5w/0/da"><img src="http://feedads.g.doubleclick.net/~a/AYux5d5cdCsYD4wwigWLwkETe5w/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/AYux5d5cdCsYD4wwigWLwkETe5w/1/da"><img src="http://feedads.g.doubleclick.net/~a/AYux5d5cdCsYD4wwigWLwkETe5w/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-06-25/creating-a-grid-of-images-for-an-album-in-drupal/1046/feed</wfw:commentRss>
		<slash:comments>36</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-06-25/creating-a-grid-of-images-for-an-album-in-drupal/1046</feedburner:origLink></item>
		<item>
		<title>Create an album based image gallery in Drupal 6 using CCK and views</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/3U8_Q-DoPuY/1045</link>
		<comments>http://jamestombs.co.uk/2009-05-12/create-an-album-based-image-gallery-in-drupal-6-using-cck-and-views/1045#comments</comments>
		<pubDate>Tue, 12 May 2009 21:32:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[albums]]></category>
		<category><![CDATA[cck]]></category>
		<category><![CDATA[content construction kit]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[imagecache]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/2009-05-12/create-an-album-based-image-gallery-in-drupal-6-using-cck-and-views/1045</guid>
		<description><![CDATA[This tutorial is an addition to my previous tutorial on creating a simple gallery in Drupal 6 using CCK and views.&#160; This tutorial will enable users to create galleries containing multiple images per node with each album being listed within a view presented by one of the node’s images.
This tutorial was written with the following [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is an addition to my previous tutorial on <a href="http://jamestombs.co.uk/2009-03-18/create-a-simple-image-gallery-in-drupal-6-using-cck-and-views/996">creating a simple gallery in Drupal 6 using CCK and views</a>.&#160; This tutorial will enable users to create galleries containing multiple images per node with each album being listed within a view presented by one of the node’s images.</p>
<p>This tutorial was written with the following versions of Drupal and module:</p>
<ul>
<li><a href="http://drupal.org/drupal-6.11">Drupal 6.11</a> </li>
<li><a href="http://drupal.org/project/cck">CCK (Content Construction Kit) 6.x-2.2</a> </li>
<li><a href="http://drupal.org/project/views">Views 6.x-2.5</a> </li>
<li><a href="http://drupal.org/project/filefield">Filefield 6.x-3.0</a> </li>
<li><a href="http://drupal.org/project/imagefield">Imagefield 6.x-3.0</a> </li>
<li><a href="http://drupal.org/project/imageapi">ImageAPI 6.x-1.6</a> </li>
<li><a href="http://drupal.org/project/imagecache">Imagecache 6.x-2.0-beta9</a> </li>
<li><a href="http://drupal.org/project/lightbox2">Lightbox2 6.x-1.9</a> </li>
</ul>
<p><strong>Note:</strong> These were the latest versions as of writing this tutorial.</p>
</p>
<p> <span id="more-1045"></span>
</p>
<h3>Installation</h3>
<p>Install Drupal as normal and extract each of the modules to /sites/all/modules directory.</p>
<p>Navigate to /admin/build/modules and enable the following modules:</p>
<ul>
<li>Content </li>
<li>Filefield </li>
<li>Imagefield </li>
<li>ImageAPI </li>
<li>ImageAPI GD2 (unless your server is configured for Imagemagick, then enable the ImageMagick module instead) </li>
<li>ImageCache </li>
<li>ImageCache UI </li>
<li>Lightbox2 </li>
<li>Views </li>
<li>Views UI </li>
</ul>
<p>Once you have ticked all the modules, press Save configuration.</p>
<h3>Imagecache</h3>
<p>You may wish to create more presets, but for this tutorial we will just create 2, a thumbnail for each image and a larger lightbox image.</p>
<p>Navigate to /admin/build/imagecache and click Add new preset.</p>
<p>Set the preset Namespace to thumbnail. Click Add Scale and Crop, set the width to 300 and the height to 200.</p>
<p>Then create a new imagecache preset with the name lightbox. This time select Add Scale and set the width to 800 and the height to 600.</p>
<h3>CCK Imagefield</h3>
<p>We will need to create a content type that we will use for our albums.&#160; To keep this simple, I am calling mine Album with the machine name album.</p>
<p>Navigate to /admin/content/types and click Add content type.</p>
<p>Under Submission form settings, set the Title field name to Album name and set the Body field label to description.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image.png" width="420" height="144" /></p>
<p>Save the content type.</p>
<p>Next to the Album content type click manage fields. In the Add New field area, set the label to Images and the field name to images (to make it field_images), for the Type of data to store, select File then for Form element select Image.&#160; Press Save.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb.png" width="420" height="60" /></a></p>
<p>You may need to set the Permitted upload file extensions.&#160; By default mine was set to <em>txt</em>.&#160; Change this to <em>jpg gif jpeg png</em>.</p>
<p>Under Global settings, tick the Required box and set the Number of values to Unlimited.&#160; Leave the List field disabled and set the Description field to Enabled.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image2.png" width="420" height="295" /></p>
<p>Then press the Save field settings button.</p>
<p>Now click the Display fields tab at the top of the page.</p>
<p>Set the Label to Hidden and set both the Teaser and Full node to Lightbox2: thumbnail-&gt;lightbox.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb1.png" width="420" height="45" /></a></p>
<p>Now under /node/add/album we can add some images to go in to our album.</p>
<p>For now create 3 or 4 albums.</p>
<p>Under /admin/content/node you should now have some nodes.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb2.png" width="420" height="95" /></a></p>
<h3>Views</h3>
<p>Navigate to /admin/build/views and click the Add tab at the top of the page.&#160; Set the view name to something like albums, leave the View type set to node and click Next.</p>
<p>Set the title to Albums. For Style set to Grid then chose 3 columns and set Alignment to Horizontal.</p>
<p>For Use pager set to Full pager.&#160; Then for Items per page, set to a multiple of 3, I am going to use 9 to give us a 3×3 grid of images. If you wish, you can set Use AJAX to Yes to stop the whole page being loaded on the pager.</p>
<p>Add the following Filters:</p>
<ul>
<li>Node: Published = On </li>
<li>Node: Type = Album </li>
</ul>
<p>Under Fields select Content: Images (field_images), Node: Body and&#160; Node: Title.</p>
<p>Set Label to None and change Format to thumbnail image and set the Show value to 1 value. Tick the box that says Link this field to its node, this will allow the image to be clickable. Press Update.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb3.png" width="420" height="239" /></a></p>
<p>For node body, delete the text in the Label field and press Update.&#160; If you have used long descriptions for your albums, you may wish to use the Trim this field to maximum length to limit the length of the description.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb4.png" width="420" height="262" /></a></p>
<p>For title, delete the Label text and tick the box next to Link this field to its node, press Update.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image7.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb5.png" width="420" height="163" /></a></p>
<p>At the moment Drupal has these fields in the wrong order, so you will need to click the up and down arrow next to the + button on fields.</p>
<p>And reorder the fields in to the following order: Image –&gt; Title –&gt; Body or if you wish you can keep them how they are.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb6.png" width="420" height="90" /></a></p>
<p>Under Relationships, click the + button and select Content: Images (field_images) – fid.</p>
<p>Tick the box that says Require this relationship and set the Delta to 1.&#160; This will check to make sure that the album contains at least 1 image.&#160; Setting Delta to all will result in odd behaviour in the album due to duplicates.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb7.png" width="420" height="126" /></a></p>
<p>If you wish you can add some sort criteria so that the newest albums appear first etc.</p>
<p>On the left select Page from the drop down and click Add display.</p>
<p>Under Path set to albums.</p>
<p>Press Save.</p>
<p>Now if you navigate to /albums you can see your gallery in action.</p>
<p><a href="http://jamestombs.co.uk/wp-content/uploads/2009/05/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://jamestombs.co.uk/wp-content/uploads/2009/05/image-thumb8.png" width="420" height="253" /></a></p>
<p>For your album nodes, you can modify them however you want to get the display you are looking for, whether you use Panels or create a custom node-album.tpl.php is up to you.</p>
<p><strong>Update:</strong> I have now written a tutorial on <a href="http://jamestombs.co.uk/2009-06-25/creating-a-grid-of-images-for-an-album-in-drupal/1046">creating a grid of images within an album using the node-album.tpl.php method</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/53v9ZddVrh-RDtT9VY47YNOXWss/0/da"><img src="http://feedads.g.doubleclick.net/~a/53v9ZddVrh-RDtT9VY47YNOXWss/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/53v9ZddVrh-RDtT9VY47YNOXWss/1/da"><img src="http://feedads.g.doubleclick.net/~a/53v9ZddVrh-RDtT9VY47YNOXWss/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-05-12/create-an-album-based-image-gallery-in-drupal-6-using-cck-and-views/1045/feed</wfw:commentRss>
		<slash:comments>59</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-05-12/create-an-album-based-image-gallery-in-drupal-6-using-cck-and-views/1045</feedburner:origLink></item>
		<item>
		<title>Fatal error: Unsupported operand types in email_registration.module on line 61</title>
		<link>http://feedproxy.google.com/~r/JamesTombs/~3/i8NRJHskWUE/1023</link>
		<comments>http://jamestombs.co.uk/2009-04-22/fatal-error-unsupported-operand-types-in-cxampphtdocsdrupalsitesallmodulesemail_registrationemail_registrationmodule-on-line-61/1023#comments</comments>
		<pubDate>Wed, 22 Apr 2009 21:01:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[email_registration]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[logintoboggan]]></category>
		<category><![CDATA[problem]]></category>

		<guid isPermaLink="false">http://jamestombs.co.uk/2009-04-22/fatal-error-unsupported-operand-types-in-cxampphtdocsdrupalsitesallmodulesemail_registrationemail_registrationmodule-on-line-61/1023</guid>
		<description><![CDATA[You will get this error if you have logintoboggan and email_registration installed within Drupal 5 and visit the site as an anonymous user with the user login block enabled.&#160; This is caused by the modifications made to the user login block by the logintoboggan module.
You can fix this without hacking the email_registration.module file.
 
Fix
While logged [...]]]></description>
			<content:encoded><![CDATA[<p>You will get this error if you have <a href="http://drupal.org/project/logintoboggan">logintoboggan</a> and <a href="http://drupal.org/project/email_registration">email_registration</a> installed within Drupal 5 and visit the site as an anonymous user with the user login block enabled.&#160; This is caused by the modifications made to the user login block by the <a href="http://drupal.org/project/logintoboggan">logintoboggan</a> module.</p>
<p>You can fix this without hacking the email_registration.module file.</p>
<p> <span id="more-1023"></span><br />
<h3>Fix</h3>
<p>While logged in as an admin (if you can’t get in to the site to login, go to <a href="http://www.domain.com/user">http://www.domain.com/user</a>, as this will only load up the main user login form and not the block), go to Admin –&gt; Site Building –&gt; Blocks.&#160; Click Configure next to User login.&#160; Under Block type, select the radio button that says Standard. Then save the block.&#160; Now try to visit the site as an anonymous user and it should be working.</p>
<h3>Hack fix</h3>
<p>Within the email_registration.module file, you will need to add some code to the module.</p>
<p>On lines 59-62, you will find the following:</p>
<p><code>case 'user_login_block':     <br />&#160; $form['name']['#title'] = t('E-mail');       <br />&#160; </code><code>$form['#validate'] = array('email_registration_user_login_validate' =&gt; array()) + $form['#validate'];      <br />&#160; </code><code>break;</code></p>
<p>You need to change it to this:</p>
<p><code>case 'user_login_block':     <br />&#160; if (!empty($form[‘#validate’)) {</code><code>     <br />&#160;&#160;&#160; $form['name']['#title'] = t('E-mail');       <br />&#160;&#160;&#160; </code><code>$form['#validate'] = array('email_registration_user_login_validate' =&gt; array()) + $form['#validate'];     <br />&#160; }      <br />&#160; </code><code>break;</code></p>
<p>Save the module and it should work as expected.</p>
<h3>The problem</h3>
<p>Logintoboggan adds the ability to change the appearance of the user login block to show just a link rather than the form that Drupal usually ships with, this in turn means that there are no $form array elements for hook_form_alter to use.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/bjwFPCXTFSjIzo8nW29Stcm2_Rc/0/da"><img src="http://feedads.g.doubleclick.net/~a/bjwFPCXTFSjIzo8nW29Stcm2_Rc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/bjwFPCXTFSjIzo8nW29Stcm2_Rc/1/da"><img src="http://feedads.g.doubleclick.net/~a/bjwFPCXTFSjIzo8nW29Stcm2_Rc/1/di" border="0" ismap="true"></img></a></p>]]></content:encoded>
			<wfw:commentRss>http://jamestombs.co.uk/2009-04-22/fatal-error-unsupported-operand-types-in-cxampphtdocsdrupalsitesallmodulesemail_registrationemail_registrationmodule-on-line-61/1023/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://jamestombs.co.uk/2009-04-22/fatal-error-unsupported-operand-types-in-cxampphtdocsdrupalsitesallmodulesemail_registrationemail_registrationmodule-on-line-61/1023</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 13.186 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-11-21 11:11:37 --><!-- Compression = gzip -->
