<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Web wok</title>
	<atom:link href="http://webwok.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://webwok.wordpress.com</link>
	<description>everyday recipes for the web cuisine</description>
	<lastBuildDate>Tue, 04 Aug 2009 09:35:22 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='webwok.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/0db2307c6544ac555349751a109889d6?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Web wok</title>
		<link>http://webwok.wordpress.com</link>
	</image>
			<item>
		<title>Auto-complete Select menu with Jquery, Ajax and MySQL</title>
		<link>http://webwok.wordpress.com/2009/08/04/auto-complete-select-menu-with-jquery-ajax-and-mysql/</link>
		<comments>http://webwok.wordpress.com/2009/08/04/auto-complete-select-menu-with-jquery-ajax-and-mysql/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 09:34:20 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[MyHouseMyStreet]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=132</guid>
		<description><![CDATA[Problem:
How to automatically populate the options of a select menu, when the user selects an option from another menu.
We encountered this problem in the MyHouseMyStreet project. We had a select menu of streets and one of buildings within each street. We wanted that everytime the user selected a street, the buildings of that street appeared [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=132&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h3>Problem:</h3>
<p>How to automatically populate the options of a select menu, when the user selects an option from another menu.</p>
<p>We encountered this problem in the MyHouseMyStreet project. We had a select menu of streets and one of buildings within each street. We wanted that everytime the user selected a street, the buildings of that street appeared in another select menu.</p>
<h3>Solution:</h3>
<p>First of all, we add the select menus in the HTML code. The one containing the streets is populated from a table in the database.</p>
<p>The select menu for the buildings contains no options as these will be added by the javascript code.</p>
<p>Then we add the javascript code, which is activated everytime the user changes option in the streets&#8217;menu.  The javascript sends a post request to the server passing the id of the street for which we need to retrieve the buildings and specifies the action requested (in this case to get the buildings &#8211; this is used so that you can use the php files to handle other requests as well).</p>
<p>The php retrieves the buildings associated to that street using the idstreet passed by the javascript and returns them in a JSON array.</p>
<p>The javascript receives the results and parses them.</p>
<p><strong>Requirements:</strong></p>
<p>jquery library</p>
<h3>Code:</h3>
<p><strong>The Javascript code</strong></p>
<pre>//update buildings select menu as soon as a street is selected
$('#idstreet').change(function(){
 var idstreet=$('#idstreet').val();
 $.post("code/search_manage.php", { 'action': "getbuildings",  'idstreet': ""+idstreet+""},
 function(data){
 var buildings = data;
 var options = '';
 for (var i = 0; i &lt;buildings.length; i++) {
 options += '&lt;option value="' + buildings[i].optionValue + '"&gt;' + buildings[i].optionDisplay + '&lt;/option&gt;';
 }
 options += '&lt;option value="all" selected&gt;all&lt;/option&gt;';
 $("select#idbuilding").html(options);
 }, "json");
 return false;
 });</pre>
<p><strong>The HTML code</strong></p>
<pre>&lt;select name="idstreet" id="idstreet"&gt;
 &lt;?
 $db=open_db();
 $db-&gt;open("SELECT * FROM street ORDER BY street_name");
 $streets=NULL;
 if(!$db-&gt;eof){
 while(!$db-&gt;eof){
 $streets[]=$db-&gt;get_row();
 }
 }
foreach($streets as $street){?&gt;
 &lt;option value="&lt;?=$street['idstreet']?&gt;"&gt;&lt;?=$street['street_name']?&gt;&lt;/option&gt;
 &lt;? }?&gt;&lt;/select&gt;
&lt;select name="idbuilding" id="idbuilding"&gt;&lt;/select&gt;</pre>
<p><strong>The PHP server code</strong></p>
<pre>$action=isset($_POST['action'])?$_POST['action']:'';
if($action=="getbuildings"){
 $db=open_db();
 $db-&gt;open("SELECT * FROM building WHERE street_idstreet=".$_POST['idstreet']." ORDER BY bnum_name");
 $buildings="[";
 if(!$db-&gt;eof){
 while(!$db-&gt;eof){
 //$buildings['optionValue']=$db-&gt;read_field('idbuilding');
 //$buildings['optionDisplay']=$db-&gt;read_field('bnum_name');
 $buildings.= '{optionValue:'.$db-&gt;read_field('idbuilding').', optionDisplay: "'.$db-&gt;read_field('bnum_name').'"},';
 $db-&gt;nextrow();
 }
 }
 $db-&gt;close();
 $buildings=substr($buildings,0,strlen($buildings)-1);
 $buildings.="]";
 echo &lt;&lt;&lt;HERE_DOC
$buildings
HERE_DOC;

 exit();
}</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=132&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2009/08/04/auto-complete-select-menu-with-jquery-ajax-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>CSS easy layout</title>
		<link>http://webwok.wordpress.com/2009/06/10/css-easy-layout/</link>
		<comments>http://webwok.wordpress.com/2009/06/10/css-easy-layout/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 10:41:34 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=129</guid>
		<description><![CDATA[My advice si to forget the ruler and download Blueprint . Blueprint is a CSS framework, which gives you a grid to place your elements and basic, clean typography.
One issue with the grid provided by Blueprint is that the footer doesn&#8217;t stick to the bottom of the page.
However, there is a hack for this, which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=129&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>My advice si to forget the ruler and download <a href="http://www.blueprintcss.org/" target="_blank">Blueprint</a> . Blueprint is a <strong>CSS framework</strong>, which gives you a grid to place your elements and basic, clean typography.</p>
<p>One issue with the grid provided by Blueprint is that the footer doesn&#8217;t stick to the bottom of the page.</p>
<p>However, there is a hack for this, which described below.</p>
<p><strong>How to keep the footer at the bottom of the page</strong></p>
<p>Your CSS:</p>
<p>* {<br />
margin: 0;<br />
}<br />
html, body {<br />
height: 100%;<br />
}<br />
.wrapper {<br />
min-height: 100%;<br />
height: auto !important;<br />
height: 100%;<br />
margin: 0 auto -4em;<br />
}<br />
.footer, .push {<br />
height: 4em;</p>
<p>}</p>
<p>The HTML:</p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;layout.css&#8221; &#8230; /&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div&gt;<br />
&lt;p&gt;Your website content here.&lt;/p&gt;<br />
&lt;div&gt;&lt;/div&gt;<br />
&lt;<span>/</span>div&gt;<br />
&lt;div&gt;<br />
&lt;p&gt;Copyright (c) 2008&lt;/p&gt;<br />
&lt;<span>/</span>div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>from <a href="http://ryanfait.com/resources/footer-stick-to-bottom-of-page/" target="_blank">Ryan Fait&#8217;s blog post</a> .</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=129&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2009/06/10/css-easy-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>make MySQL transactions work in PHP</title>
		<link>http://webwok.wordpress.com/2009/03/27/make-mysql-transactions-work-in-php/</link>
		<comments>http://webwok.wordpress.com/2009/03/27/make-mysql-transactions-work-in-php/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 20:03:17 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=126</guid>
		<description><![CDATA[Requirements:

All tables involved in the transactions in your database must be TYPE=InnoDB.
I am using a library to connect to the database. However, if you are familiar with the PHP mysql API  functions , you can replace the library calls with the API calls. The general concept is still valid.

Step.1 The PHP wrapper 
Create php functions [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=126&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Requirements:</strong></p>
<ol>
<li>All tables involved in the transactions in your database must be TYPE=InnoDB.</li>
<li>I am using a library to connect to the database. However, if you are familiar with the PHP mysql API  functions , you can replace the library calls with the API calls. The general concept is still valid.</li>
</ol>
<p><strong>Step.1 The PHP wrapper </strong></p>
<p>Create php functions to wrap the mysql queries that implement the transaction syntax.</p>
<pre>&lt;?php

//transactions
function begin()
{
@mysql_query("BEGIN");
}
function commit()
{
@mysql_query("COMMIT");
}
function rollback()
{
@mysql_query("ROLLBACK");
}

?&gt;</pre>
<p>Implement a function to return the value of the last id inserted (this will be used to check that the query has been performed successfully).</p>
<pre>//get id from the last inserted record
function get_last_inserted_id($table)
{
    $q = "SELECT LAST_INSERT_ID() FROM $table";
    return mysql_num_rows(mysql_query($q));
}</pre>
<p><strong>Step.2 The main code</strong></p>
<p>To test it, say you have two tables &#8216;project&#8217; and &#8217;street&#8217;. You want to insert a new project in the project table and a new street for that project  into the street table.</p>
<p>If any of the two transactions don&#8217;t work, mysql will rollback, and therefore no records will be inserted.</p>
<p>Note: you can put as many queries as you want between begin() and commit()/rollback().</p>
<p>begin(); // transaction begins<br />
$db=open_db();<br />
//add to projects<br />
$db-&gt;add_record(&#8216;project&#8217;,$fields);<br />
$prj_id=$db-&gt;get_inserted_id();<br />
//add to street<br />
$db-&gt;add_record(&#8217;street&#8217;,$fields);<br />
$street_id=get_last_inserted_id(&#8217;street&#8217;);<br />
echo (&#8220;&lt;BR&gt;&#8221;.$prj_id.&#8221; &#8220;.$street_id);<br />
$db-&gt;close();<br />
if(!$prj_id||!$street_id)<br />
{<br />
rollback(); // transaction rolls back<br />
echo &#8220;you rolled back&#8221;;<br />
exit;<br />
}<br />
else<br />
{<br />
commit(); // transaction is committed<br />
echo &#8220;your insertion was successful&#8221;;<br />
exit;<br />
}</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=126&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2009/03/27/make-mysql-transactions-work-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>Get the difference between two arrays in PHP</title>
		<link>http://webwok.wordpress.com/2009/03/26/get-the-difference-between-two-arrays-in-php/</link>
		<comments>http://webwok.wordpress.com/2009/03/26/get-the-difference-between-two-arrays-in-php/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 15:22:39 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=124</guid>
		<description><![CDATA[This is a little useful function which gets all the elements that are in one array but not in another.
/*
It returns all the elements in array $b that do not appear in array $a.
*/
function array_sub_array($a, $b) {
$tot=count($b);
       for($i=0;$i&#60;$tot;$i++){
              if(!in_array($b[$i],$a)){$c[]=$b[$i];}

        }
        $c=array_filter($c);//HACK: delete NULL values
        return $c;
}
      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=124&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is a little useful function which gets all the elements that are in one array but not in another.</p>
<pre>/*
It returns all the elements in array $b that do not appear in array $a.
*/
function array_sub_array($a, $b) {
$tot=count($b);
       for($i=0;$i&lt;$tot;$i++){
              if(!in_array($b[$i],$a)){$c[]=$b[$i];}

        }
        $c=array_filter($c);//HACK: delete NULL values
        return $c;
}</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=124&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2009/03/26/get-the-difference-between-two-arrays-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>prev/next navigation in Plone</title>
		<link>http://webwok.wordpress.com/2009/03/16/prevnext-navigation-in-plone/</link>
		<comments>http://webwok.wordpress.com/2009/03/16/prevnext-navigation-in-plone/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 12:52:21 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[Bevan Letters]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[bevan letter]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[plone 3.0]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=118</guid>
		<description><![CDATA[Problem:
being able to navigate through the items of a Plone folder as you browse them.
case-study:
I had several images and other documents all in the same folder. As they  landed on a page, I wanted users to be able to navigate to the previous / next image without having to go back to the root folder.
Solution:

retrieve [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=118&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Problem:</strong></p>
<p>being able to navigate through the items of a Plone folder as you browse them.</p>
<p><em>case-study:</em></p>
<p>I had several images and other documents all in the same folder. As they  landed on a page, I wanted users to be able to navigate to the previous / next image without having to go back to the root folder.</p>
<p><strong>Solution:</strong></p>
<ol>
<li>retrieve the objects  from the folder</li>
<li>place them in a list</li>
<li>get the position of the current object in the list</li>
<li>calculate the previous and next positions from the current position (-1 and +1, respectively)</li>
<li>create the links to these objects (remember to add the template at the end of the object&#8217;s url if you have a customised view for such object)</li>
</ol>
<p><strong>Implementation:</strong></p>
<pre>&lt;div metal:fill-slot="main"&gt;
&lt;div  tal:define=".....
chapters python:here.aq_parent.getFolderContents(contentFilter = {'portal_type' : ['BevanLetterImage']});
 sibl     python:[p for p in chapters];
 numsibl python:len(sibl);
 pos     python: [i for i in range(numsibl)if sibl[i].getId == here.getId()][0]" &gt;
&lt;!--prev next nav--&gt;
 &lt;div class="listingBar" tal:condition="python: next or prev"
 tal:define="next python:pos &lt; numsibl-1;
 prev python:pos != 0;"&gt;
 &lt;span tal:condition="next"&gt;
 &lt;a class="listingNext"
 tal:define="nextsib python:sibl[pos+1]"
 tal:attributes="href string:${nextsib/getURL}/view"
 tabindex="1"
 href=""&gt;
 &lt;span i18n:translate="label_next"&gt;
 Next: &lt;/span&gt;
 &lt;span tal:replace="nextsib/Title" /&gt;
 &lt;/a&gt;
 &lt;/span&gt;
 &lt;span tal:condition="prev"&gt;
 &lt;a class="listingPrevious"
 tal:define="prevsib python:sibl[pos-1]"
 tal:attributes="href string:${prevsib/getURL}/view"
 tabindex="2"
 href=""&gt;
 &lt;span i18n:translate="label_previous"&gt;
 Previous: &lt;/span&gt;
 &lt;span tal:replace="prevsib/Title" /&gt;
 &lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
&lt;div style="clear:both"&gt;&lt;/div&gt;
&lt;!--end prev next nav--&gt;</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=118&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2009/03/16/prevnext-navigation-in-plone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>Displaying  folder contents in Plone</title>
		<link>http://webwok.wordpress.com/2009/02/16/displaying-folder-contents-in-plone/</link>
		<comments>http://webwok.wordpress.com/2009/02/16/displaying-folder-contents-in-plone/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 11:42:47 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[Bevan Letters]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=110</guid>
		<description><![CDATA[Problem:
retrieve only specific contents of a Plone folder, order the list by a customised criteria (i.e. date, title) and display some of their related info.
case-study:
I have a letter with related images ( a customised product that I created, called &#8220;BevanLetterImage&#8221;)  in one folder. I want to display the images below the letter and order them [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=110&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h3>Problem:</h3>
<p>retrieve only specific contents of a Plone folder, order the list by a customised criteria (i.e. date, title) and display some of their related info.</p>
<p><em>case-study:</em></p>
<p>I have a letter with related images ( a customised product that I created, called &#8220;BevanLetterImage&#8221;)  in one folder. I want to display the images below the letter and order them by title.</p>
<h3>Solution:</h3>
<p>create a list which displays from the folder contents only the images and specify the title as the  sortable criteria.</p>
<h3>Implementation:</h3>
<p>Insert the following code in the part of the template where you want the list to show.</p>
<p>The code retrieves only the object of type<em> aType</em> and according to criteria <em>sortable_criteria </em>(examples of criteria: &#8216;<em>sortable_title&#8217;, &#8216;Date&#8217;</em>).</p>
<p>For each image it displays the title and the image as a thumbnail. Both are also rendered as links to the real image.</p>
<pre>&lt;!--image list--&gt;
&lt;div id="photo-holder"&gt;
 &lt;tal:foldercontents define="contentFilter contentFilter|request/contentFilter|nothing;
                            limit_display limit_display|request/limit_display|nothing;
                            more_url more_url|request/more_url|string:folder_contents;
                            contentsMethod python:test(here.portal_type=='Topic', here.queryCatalog, here.getFolderContents);
                            folderContents folderContents|python:contentsMethod(contentFilter={'sort_on':'<strong><em>sortable_criteria</em></strong>','portal_type':['<strong><em>aType</em></strong>']}, batch=True);
                            use_view_action site_properties/typesUseViewActionInListings|python:();
                            over_limit python: limit_display and len(folderContents) &gt; limit_display;
                            folderContents python: (over_limit and folderContents[:limit_display]) or folderContents;
                            batch folderContents"&gt;
&lt;h3&gt;Photos of the original letter (&lt;span tal:content="python:len(folderContents)"&gt;&lt;/span&gt; in total)&lt;/h3&gt;

 &lt;tal:listing condition="folderContents"&gt;

            &lt;tal:block tal:repeat="item folderContents"&gt;
                &lt;div  tal:define="item_url item/getURL|item/absolute_url;
                                       item_id item/getId|item/id;
                                       item_title_or_id item/pretty_title_or_id;
                                       item_description item/Description;
                                       item_type item/portal_type;
                                       item_type_title item/Type;"&gt;
&lt;!-- custom --&gt;                  
 &lt;a  href="#"
                       tal:attributes="href python:item_url+'/view'"&gt;&lt;p class="photo-title" tal:content="item_title_or_id"&gt;&lt;/p&gt;
  &lt;img src="" alt="" tal:attributes="src python:item_url+'/image_thumb'"  /&gt;
                    &lt;/a&gt;
&lt;!-- end of custom --&gt;
               &lt;/div&gt;
 &lt;/tal:block&gt;
 &lt;/tal:listing&gt;
 &lt;/tal:foldercontents&gt;
 &lt;/div&gt;  &lt;div style="clear:both"&gt;&lt;/div&gt;
&lt;!--end of image list--&gt;</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=110&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2009/02/16/displaying-folder-contents-in-plone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>Rotate and zoom images with Javascript</title>
		<link>http://webwok.wordpress.com/2008/11/17/rotate-and-zoom-images-with-javascript/</link>
		<comments>http://webwok.wordpress.com/2008/11/17/rotate-and-zoom-images-with-javascript/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 12:11:38 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[scripts and tips]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=98</guid>
		<description><![CDATA[A Javascript script to rotate and zoom images using the canvas element.
Installation
in the BODY of your html page insert the commands which will trigger the transformations and the image you want to rotate, embedded in a canvas element:
&#60;body onload="CanvasOnload()"&#62;
&#60;h1&#62;Image rotate and zoom&#60;/h1&#62;
    &#60;span style="text-align: center; width: 65px"&#62;
      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=98&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A Javascript script to rotate and zoom images using the <a href="http://en.wikipedia.org/wiki/Canvas_(HTML_element)" target="_blank">canvas element</a>.</p>
<p><strong>Installation</strong></p>
<p>in the BODY of your html page insert the commands which will trigger the transformations and the image you want to rotate, embedded in a canvas element:</p>
<pre>&lt;<span class="start-tag">body</span><span class="attribute-name"> onload</span>=<span class="attribute-value">"CanvasOnload()"</span>&gt;</pre>
<pre>&lt;<span class="start-tag">h1</span>&gt;Image rotate and zoom&lt;/<span class="end-tag">h1</span>&gt;
    &lt;<span class="start-tag">span</span><span class="attribute-name"> style</span>=<span class="attribute-value">"text-align: center; width: 65px"</span>&gt;
        &lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"javascript: location.href = 'index.html'" </span><span class="attribute-name">style</span>=<span class="attribute-value">"text-decoration: none"</span>&gt;
            &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"reset.png" </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Reset the image" </span><span class="attribute-name">border</span>=<span class="attribute-value">"0" </span><span class="error"><span class="attribute-name">/</span></span>&gt;
        &lt;/<span class="end-tag">a</span>&gt;
    &lt;/<span class="end-tag">span</span>&gt;

&lt;<span class="start-tag">p</span>&gt;
	rotate:
	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"0°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(0);"</span>&gt;</pre>
<pre>	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"90°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(90);"</span>&gt;
	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"180°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(180);"</span>&gt;
	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"-90°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(-90);"</span>&gt;
&lt;/<span class="end-tag">p</span>&gt;

&lt;<span class="start-tag">div</span>&gt;
    &lt;<span class="start-tag">span</span><span class="attribute-name"> style</span>=<span class="attribute-value">"text-align: center; width: 65px"</span>&gt;
        &lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"#"
           </span><span class="attribute-name">onmousedown</span>=<span class="attribute-value">"mousedown = true; ZoomOut(document.getElementById('myimage'))"
           </span><span class="attribute-name">onmouseout</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">onmouseup</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">style</span>=<span class="attribute-value">"text-decoration: none"</span>&gt;
            &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"minus.jpg" </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Zoom out" </span><span class="attribute-name">border</span>=<span class="attribute-value">"0" </span><span class="error"><span class="attribute-name">/</span></span>&gt;
        &lt;/<span class="end-tag">a</span>&gt;</pre>
<pre>    &lt;/<span class="end-tag">span</span>&gt;
    &lt;<span class="start-tag">span</span><span class="attribute-name"> style</span>=<span class="attribute-value">"text-align: center; width: 65px"</span>&gt;
        &lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"#"
           </span><span class="attribute-name">onmousedown</span>=<span class="attribute-value">"mousedown = true; ZoomIn(document.getElementById('myimage'))"
           </span><span class="attribute-name">onmouseup</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">onmouseout</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">style</span>=<span class="attribute-value">"text-decoration: none"</span>&gt;
            &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"plus.jpg" </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Zoom in" </span><span class="attribute-name">border</span>=<span class="attribute-value">"0" </span><span class="error"><span class="attribute-name">/</span></span>&gt;
        &lt;/<span class="end-tag">a</span>&gt;
    &lt;/<span class="end-tag">span</span>&gt;
&lt;/<span class="end-tag">div</span>&gt;

&lt;<span class="start-tag">canvas</span><span class="attribute-name"> id</span>=<span class="attribute-value">"ff_canvas" </span><span class="attribute-name">width</span>=<span class="attribute-value">"159" </span><span class="attribute-name">height</span>=<span class="attribute-value">"198"</span>&gt;
    &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"/js-tests/rotateImage/fashionable.jpg"
         </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Zend"
         </span><span class="attribute-name">width</span>=<span class="attribute-value">"159"
         </span><span class="attribute-name">height</span>=<span class="attribute-value">"198"
         </span><span class="attribute-name">id</span>=<span class="attribute-value">"myimage"
         </span><span class="attribute-name">style</span>=<span class="attribute-value">"margin-left: 50px; position: absolute; top: 110px; left: 250px; cursor: hand" </span><span class="error"><span class="attribute-name">/</span></span>&gt;</pre>
<pre>&lt;/<span class="end-tag">canvas</span>&gt;
&lt;/body&gt;</pre>
<p>In the HEAD of your html page, you need to insert the references to your scripts:</p>
<pre>&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text/javascript" </span><span class="attribute-name">src</span>=<span class="attribute-value">"imgRotateCanvas.js"</span>&gt;&lt;/<span class="end-tag">script</span>&gt;
&lt;<span class="start-tag">script</span><span class="attribute-name"> language</span>=<span class="attribute-value">"javascript" </span><span class="attribute-name">src</span>=<span class="attribute-value">"imgZoomCanvas.js"</span>&gt;&lt;/<span class="end-tag">script</span>&gt;</pre>
<p>This is the code in &#8220;imgRotateCanvas.js&#8221;:</p>
<pre>/*Author: Val Cartei,  val.cartei@gmail.com.
Year:2008
Description: rotates an image embedded in a canvas element.

This script is an adaptation of a script by: Benoit Asselin | http://www.ab-d.fr. The original script can be found at:
The JavaScript Source!! http://javascript.internet.com
*/

/**
*function: rotate
* @param int p_deg - the degrees of the rotation (e.g. -90,180,270,0).
*/
function rotate(p_deg) {
	if(document.getElementById('ff_canvas')) {
		/*
		Ok!: Firefox 2, Safari 3, Opera 9.5b2
		No: Opera 9.27
		*/
		var image = document.getElementById('myimage');
		var canvas = document.getElementById('ff_canvas');
		var canvasContext = canvas.getContext('2d');

		switch(p_deg) {
			default :
			case 0 :
				canvas.setAttribute('width', image.width);
				canvas.setAttribute('height', image.height);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, 0, 0);
				break;
			case 90 :
				canvas.setAttribute('width', image.height);
				canvas.setAttribute('height', image.width);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, 0, -image.height);
				break;
			case 180 :
				canvas.setAttribute('width', image.width);
				canvas.setAttribute('height', image.height);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, -image.width, -image.height);
				break;
			case 270 :
			case -90 :
				canvas.setAttribute('width', image.height);
				canvas.setAttribute('height', image.width);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, -image.width, 0);
				break;
		};

	} else {
		/*
		Ok!: MSIE 6 et 7
		*/
		var image = document.getElementById('myimage');
		switch(p_deg) {
			default :
			case 0 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=0)';
				break;
			case 90 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=1)';
				break;
			case 180 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2)';
				break;
			case 270 :
			case -90 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=3)';
				break;
		};

	};
};

// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
	var image = document.getElementById('myimage');
	var canvas = document.getElementById('ff_canvas');
	if(canvas.getContext) {
		image.style.visibility = 'hidden';
		image.style.position = 'absolute';
	} else {
		canvas.parentNode.removeChild(canvas);
	};

	rotate(0);
});</pre>
<p>This is the code in &#8220;imgZoomCanvas.js&#8221;:</p>
<pre>/*Author: Val Cartei,  val.cartei@gmail.com.
 Year:2008
 Description: rotates an image embedded in a canvas element.</pre>
<pre>This script is an adaptation of a script that can be found at:
 http://www.phpguru.org/downloads/image_rotate/rotate.html
 )*/
 &lt;!--
 mousedown = false; // An important global variable</pre>
<pre>/**
 * The zoom out function
 *
 * @param object obj The image object
 */
 function ZoomOut(obj)
 {
 if (document.all) {
 // In case the zoom property is not set
 if (obj.style.zoom == '') {
 obj.style.zoom = 1;
 }</pre>
<pre>if (parseFloat(obj.style.zoom) &lt;= 0.1) {
 return;
 }</pre>
<pre>obj.style.zoom = obj.style.zoom - 0.1;</pre>
<pre>if (mousedown) {
 setTimeout("ZoomOut(document.getElementById('" + obj.id + "'))", obj.height);
 }
 } else {
 var canvas  = document.getElementById('ff_canvas');
 var context = canvas.getContext('2d');</pre>
<pre>canvas.style.width = ((parseInt(canvas.style.width) ? parseInt(canvas.style.width) : obj.width) - 10) + 'px';
 canvas.style.height = ((parseInt(canvas.style.height) ? parseInt(canvas.style.height) : obj.height) - 10) + 'px';</pre>
<pre>if (mousedown) {
 setTimeout("ZoomOut(document.getElementById('" + obj.id + "'))", 50);
 }
 }
 }</pre>
<pre>/**
 * The zoom in function
 *
 * @param object obj The image object
 */
 function ZoomIn(obj)
 {
 if (document.all) {
 // In case the zoom property is not set
 if (obj.style.zoom == '') {
 obj.style.zoom = 1;
 }</pre>
<pre>// Lower limit is 0.1
 if (parseFloat(obj.style.zoom) &lt;= 0.1) {
 obj.style.zoom = 0.1;
 }</pre>
<pre>obj.style.zoom = Number(obj.style.zoom) + 0.1;</pre>
<pre>if (mousedown) {
 setTimeout("ZoomIn(document.getElementById('" + obj.id + "'))", obj.width);
 }
 } else {
 var canvas  = document.getElementById('ff_canvas');
 var context = canvas.getContext('2d');</pre>
<pre>canvas.style.width = ((parseInt(canvas.style.width) ? parseInt(canvas.style.width) : obj.width)+ 10) + 'px';
 canvas.style.height = ((parseInt(canvas.style.height) ? parseInt(canvas.style.height) : obj.height)+ 10) + 'px';</pre>
<pre>if (mousedown) {
 setTimeout("ZoomIn(document.getElementById('" + obj.id + "'))", 50);
 }
 }
 }</pre>
<pre>/**
 *
 */
 function Reset(img)
 {
 img.style.zoom = 1;
 img.rotation = -0.01;
 Rotate(img, 0.01);
 }</pre>
<pre>function CanvasOnload()
 {
 // IE
 if (document.all) {
 return;
 }</pre>
<pre>var canvas  = document.getElementById('ff_canvas');
 var context = canvas.getContext('2d');
 var img     = document.getElementById('myimage');</pre>
<pre>context.drawImage(img, 0, 0, img.width, img.height);
 }</pre>
<pre>/**
 * Shows the status of the rotation
 */
 function ShowStatus()
 {
 var img  = document.getElementById('myimage');
 var zoom = Number(img.style.zoom);</pre>
<pre>alert('Zoom factor: ' + (zoom ? zoom : 1) + '\nRotation factor: ' + (img.rotation ? img.rotation : '0') );
 }
 // --&gt;</pre>
<p>These are image files used. Put them in the root directory together with your html page and the .js scripts.</p>
<p>Zoom in:</p>
<p><a href="http://webwok.files.wordpress.com/2008/11/plus.jpg"><img class="alignnone size-full wp-image-99" title="plus" src="http://webwok.files.wordpress.com/2008/11/plus.jpg?w=60&#038;h=60" alt="plus" width="60" height="60" /></a></p>
<p>ZoomOut:</p>
<p><a href="http://webwok.files.wordpress.com/2008/11/minus.jpg"><img class="alignnone size-full wp-image-100" title="minus" src="http://webwok.files.wordpress.com/2008/11/minus.jpg?w=60&#038;h=60" alt="minus" width="60" height="60" /></a></p>
<p>and the sample image:</p>
<p><a href="http://webwok.files.wordpress.com/2008/11/fashionable.jpg"><img class="alignnone size-full wp-image-101" title="fashionable" src="http://webwok.files.wordpress.com/2008/11/fashionable.jpg?w=159&#038;h=198" alt="fashionable" width="159" height="198" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=98&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/11/17/rotate-and-zoom-images-with-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>

		<media:content url="http://webwok.files.wordpress.com/2008/11/plus.jpg" medium="image">
			<media:title type="html">plus</media:title>
		</media:content>

		<media:content url="http://webwok.files.wordpress.com/2008/11/minus.jpg" medium="image">
			<media:title type="html">minus</media:title>
		</media:content>

		<media:content url="http://webwok.files.wordpress.com/2008/11/fashionable.jpg" medium="image">
			<media:title type="html">fashionable</media:title>
		</media:content>
	</item>
		<item>
		<title>Jquery, Ajax forms, PHP and Mysql at the table</title>
		<link>http://webwok.wordpress.com/2008/11/03/jquery-ajax-forms-php-and-mysql-at-the-table/</link>
		<comments>http://webwok.wordpress.com/2008/11/03/jquery-ajax-forms-php-and-mysql-at-the-table/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 16:26:06 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[scripts and tips]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=88</guid>
		<description><![CDATA[Before starting, if you have PHP.x &#60; PHP.2, you need to put into your includes folder the library jsonwrapper (this encodes/decodes json objects).
Imagine you have a form to add an item to a shop and you want to create a new category for that shop without leaving that page.
One way to do it is to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=88&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em>Before starting, if you have PHP.x &lt; PHP.2, you need to put into your includes folder the library <a href="http://www.boutell.com/scripts/jsonwrapper.tar.gz" target="_blank">jsonwrapper </a>(this encodes/decodes json objects).</em></p>
<p>Imagine you have a form to add an item to a shop and you want to create a new category for that shop without leaving that page.</p>
<p>One way to do it is to have a link &#8220;add a new category&#8221; that when clicked, shows some input fields for adding the new category (e.g. name and description) and a button to submit these data.</p>
<p>When the button is clicked, javascript detects that you do not want to send the whole form, but instead it retrieves these fields and sends them as an Ajax request to the server. The php code on the server side will get the data, perform the request (adding the category) and return some data (e.g. the new category object) to the form. Javascript waits for the response and processes it.</p>
<p>This is the general idea, now let&#8217;s have a look at the code:</p>
<p><strong>Client-side: form.php</strong></p>
<p><em>in the HEAD insert javascript:</em></p>
<pre>&lt;script language="javascript" type="text/javascript" src="/assets/inc/jquery.js"&gt;&lt;/script&gt;

&lt;script language="javascript" type="text/javascript"&gt;
$(document).ready(function(){
$("ul#add-category-fields").hide();
$("a#add-category").click(function(){
     // Show subform to add a new category
     $("ul#add-category-fields").show();
     return false;
    });

    $("#btn-add-category").click(function(){
        $("#action").val("add category");
        $("#fm_edit").submit();
    });

    $("#fm_edit").submit(function(){
        if($("#action").val()=="add category")
        {
            //data to send
            var data={'catname': $("#catname").val(),'catdescription':$("#catdescription").val(),'add': "add"};
               $.post("manage_category.php",data, function(data) {
               if(data.idshopcategory&gt;0)
               {
                    $("new category has been added").insertAfter("a#add-category");
                    $("ul#add-category-fields").hide();//hide again the fields
               }else $("&lt;br&gt;&lt;p class='alert'&gt;something went wrong, category could not be added, try adding the new category from the Categories menu.&lt;/p&gt;").insertAfter("a#add-category");
               },"json");//end post
               $("#action").val("");
               return false;
        }else{
           //send to this page for edit item processing
            $("#action").val("");
           return true;
        }
   });
});//end document ready
&lt;/script&gt;</pre>
<p>The first line imports jquery library</p>
<p>The second script tag includes Ajax interaction:</p>
<p>it dynamically displays the fields in the form that will be sent as Ajax (hidden at the beginning) and when submitted it discriminates between the whole form and the sending of these fields (&#8216;action&#8217;).</p>
<p>it retrieves those fields within the form whose values we want to send to the server and encodes them as a json object.</p>
<p>it  sends a simple POST request to a server with the data as json.</p>
<p>it handles the response by veryifing the data sent back by the server. If successful, it modifies the form and add a positive feedback, otherwise it shows a negative feedback.</p>
<p>in the BODY:</p>
<p><em>within the HTML form</em></p>
<pre>....
 &lt;input type="hidden" id="action" name="action" value=""&gt;
.....

&lt;a href="#" id="add-category"&gt;add a new category&lt;/a&gt;
   &lt;ul id="add-category-fields"&gt;
        &lt;li&gt;&lt;label for="catname"&gt;&lt;/label&gt; &lt;input type="text" id="catname" name="catname" value=""&gt;&lt;/li&gt;
        &lt;li&gt;&lt;label for="catdescription"&gt;&lt;/label&gt; &lt;input type="text" id="catdescription" name="catdescription" value=""&gt;&lt;/li&gt;
        &lt;li&gt;&lt;input type="button" name="add category" id="btn-add-category" value="Add category"&gt;&lt;/li&gt;
  &lt;/ul&gt;</pre>
<p><strong>Server-side: manage_data.php</strong></p>
<p><em>PHP code:</em></p>
<pre>&lt;?php
//initialise vars
$new_record_id=0;$name="";$description="";
//json object returned to the calling page
$foo= array(
  'idshopcategory'  =&gt;0,
  'catname'   =&gt;0,
);

require_once incpath("/jsonwrapper/jsonwrapper.php"); //encode/decode json objects for AJAX calls
//get the data from the post request sent through javascript
if(!empty($_POST["add"])){

$name=$_POST['catname'];
$description=$_POST['catdescription'];
$new_record_id= $ShopCategory-&gt;newRecord($data);
}

 //json object returned to the calling page
$foo= array(
 'idshopcategory'  =&gt;1,
 'catname'   =&gt;$name,
'catdescription'   =&gt;$description,
);
// Now encode the array to JSON format
$json = json_encode($foo);
// encode array $json to JSON string
echo $json;
die();
?&gt;</pre>
<p>it creates an array of values to be returned</p>
<p>it encodes them as a json object (using json_encode as defined in the library jsonwrapper)</p>
<p>it sends the object to the page form.php.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=88&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/11/03/jquery-ajax-forms-php-and-mysql-at-the-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>Know your users &#8211; web stats made easy</title>
		<link>http://webwok.wordpress.com/2008/10/29/know-your-users-web-stats-made-easy/</link>
		<comments>http://webwok.wordpress.com/2008/10/29/know-your-users-web-stats-made-easy/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 11:19:56 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[Web analysis]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=81</guid>
		<description><![CDATA[Google Analytics offers an easy way to get statistics of your website, but one of his major drawbacks is that
you can’t analyze historical data. Luckly, I found a software that can do that, Urchin 5.
Feed your logs into Urchin
Feed your log files into Urchin
zip your log files (e.g. logfiles.zip)
in Profiles&#62;Log manager add a new profile
the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=81&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Google Analytics offers an easy way to get statistics of your website, but one of his major drawbacks is that</p>
<p>you can’t analyze historical data. Luckly, I found a software that can do that, <a href="http://www.google.com/urchin/index.html" target="_blank">Urchin 5</a>.</p>
<p><em><strong>Feed your logs into Urchin</strong></em></p>
<p>Feed your log files into Urchin</p>
<p>zip your log files (e.g. logfiles.zip)</p>
<p>in Profiles&gt;Log manager add a new profile</p>
<p>the popup will ask you the following:</p>
<p>Log file location &#8211; choose local</p>
<p>Log file path &#8211; select the path to your zipped file ( in my case, logfiles.zip).</p>
<p>Log format &#8211; choose auto</p>
<p><em><strong>Get your reports</strong></em></p>
<p>Now click on Profiles menu again and in the table you&#8217;ll see the newly created profile listed. Click on run (the lightning icon), this will run the analysis of the log source.</p>
<p>Then, on view (the zoom icon) to see the results. These open in a separate tab and on the left you can see the menu to navigate through the different reports. The most important for me are:</p>
<p><strong>Traffic&gt;Summary,</strong> which shows totals and averages for Sessions, Pageviews, Hits, and Byte. You can see details for each of these by clicking on the corresponding item in the Traffic menu.</p>
<p><strong>Page&amp;Files&gt; Requested Pages</strong>, which  ranks the popularity of the Pages</p>
<p><strong>Page&amp;Files&gt; Downloads</strong>, ranks the popularity of all Downloads on your site by number of requests</p>
<p><strong>All Files&gt; All Files by Hits</strong>, ranks the popularity of all files on your site by number of requests, which is important to detect for example how many times a given document has been downloaded or an image been viewed.</p>
<p><strong>Navigation&gt; Entrance pages</strong>, which indicates which is thepage from which Visitors entered your website (the first page they saw).</p>
<p><strong>Referrals&gt;Referrals</strong>, which list the referring URLs (external web pages) that brought traffic to your site.</p>
<p><strong>Browers &amp;Robots&gt; Browsers</strong>, ranks the browsers used by the public to access your site.</p>
<p><strong>Browers &amp;Robots&gt; Platforms</strong>, ranks the platforms (e.g. Windows,Mac&#8230;) used by the public to access your site.</p>
<p>Each statistic can also be exported in different formats. I personally choose .doc as it appears to be the easiest to read, but you can have your data in Excel or tab separated, plain text. And of course, you can also print them.</p>
<p><strong><em>Advantages and Disadvantages</em></strong></p>
<p>A major drawback is that Urchin software is not free! The demo licence expires after 90 days.</p>
<p>A major advantage, it can be used with Google Analytics:</p>
<ol>
<li>Copy your Google Analytics <a href="answer.py?answer=55603&amp;topic=7174">tracking code</a> into a text editor.</li>
<li>Add the line in bold below to your tracking code (your actual code will contain your account and profile number in place of xxxx-x):<br />
<blockquote><p><span style="font-family:Courier New,Courier,mono;color:#666666;"><br />
</span></p>
<pre><span style="font-family:Courier New,Courier,mono;color:#666666;">&lt;script type=quot;text/javascript"&gt;</span></pre>
<pre>var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");</pre>
<pre>document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</pre>
<pre>&lt;/script&gt;</pre>
<pre><span style="font-family:Courier New,Courier,mono;color:#666666;">&lt;script type="text/javascript"&gt;</span></pre>
<pre><span style="font-family:Courier New,Courier,mono;color:#666666;"> var pageTracker = _gat._getTracker("UA-xxxxxx-x");</span></pre>
<pre><strong> pageTracker._setLocalRemoteServerMode();</strong></pre>
<pre>pageTracker._trackPageview();</pre>
<pre>&lt;/script&gt;</pre>
</blockquote>
<p><span style="color:#000000;">This additional line will serve the pageview to Urchin Software as well as Google Analytics, allowing you to gather data with both products. </span></li>
<li>Then, remove this line of code from your webpages: &lt;script src=&#8221;__utm.js&#8221; type=&#8221;text/javascript&#8221;&gt;</li>
<li><a href="answer.py?answer=55488&amp;topic=7174">Add the tracking code to each of your pages</a>.</li>
</ol>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=81&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/10/29/know-your-users-web-stats-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>Dev and Live version of a WordPress site</title>
		<link>http://webwok.wordpress.com/2008/08/01/dev-live-wordpress-site/</link>
		<comments>http://webwok.wordpress.com/2008/08/01/dev-live-wordpress-site/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 11:52:05 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[CultureGeeks]]></category>
		<category><![CDATA[scripts and tips]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=58</guid>
		<description><![CDATA[Setting up the DEV and LIVE sites
Download the wordpress installation:  http://wordpress.org/download/.
In the dev and live servers, create a new empty folder in your websites roots.
Unzip the wordpress installation and copy the files in the newly created folders.
Set up the Apache&#8217;s virtual host for your dev and remote sites.
Create a new empty database i.e. culturegeeks in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=58&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>Setting up the DEV and LIVE sites</h2>
<p>Download the wordpress installation:  <a class="external free" title="http://wordpress.org/download/" href="http://wordpress.org/download/"><strong><span style="color:#2583ad;">http://wordpress.org/download/</span></strong></a>.</p>
<p>In the dev and live servers, create a new empty folder in your websites roots.</p>
<p>Unzip the wordpress installation and copy the files in the newly created folders.</p>
<p>Set up the Apache&#8217;s virtual host for your dev and remote sites.</p>
<p>Create a new empty database i.e. culturegeeks in the dev server and another with the same name in your remote server.</p>
<p>Rename wp-example.php in wp-config.php.</p>
<p>Open wp-config.php and set the database settings so that if you are in your dev server you will connect to the dev database, otherwise it will connect to the remote database. In my case that&#8217;s what I got:</p>
<pre>switch($_SERVER['SERVER_NAME']){
 case '192.168.0.2':
 //dev site (fileserver)
 define('DB_USER', <em>'I am not gonna publish it here!'</em>);     // Your MySQL username
 define('DB_PASSWORD', <em>'I am not gonna publish it here!</em>'); // ...and password
 define('DB_HOST', '192.168.0.2');    // 99% chance you won't need to change this value
 break;
 default:
 //live site (dl320) //remote user:admin pwd:*g11eiKu9Y#E
 define('DB_USER', <em>'I am not gonna publish it here!'</em>);     // Your MySQL username
 define('DB_PASSWORD', <em>'I am not gonna publish it here!'</em>); // ...and password
 define('DB_HOST', '212.42.165.194');    // 99% chance you won't need to change this value
 break;
}
define('DB_NAME', 'culturegeeks');    // The name of the database</pre>
<p>Go to your dev website address and run the installation script:<br />
devyourwebsite/wp-admin/wp-install.php</p>
<p>This will set up the dev website.</p>
<p>Go to your live website address and run the installation script:<br />
devyourwebsite/wp-admin/wp-install.php</p>
<p>This will set up the live website.</p>
<p>You will be asked to give your blog a title and an email address. Next, you will be prompted with a username and password. Save these details, as you&#8217;ll require them when you access the website&#8217;s dashboard (admin area).</p>
<p>Set up the new site in Dreamweaver, where the local settings refer to the dev site and the remote settings your remote site&#8217;s ftp details. Test the connection is successful.</p>
<p>The two sites have now been initialized and should be exactly the same.</p>
<h2>Update your remote site</h2>
<p>Let&#8217;s say we want to make some changes to the look&amp;feel of the website. First, we will apply a new template to the dev site, twick it and then upload the changes to the live site.</p>
<p>First, download the new template. A range of free templates can be found at: <a href="http://themes.wordpress.net/">WordPress Theme Viewer</a></p>
<p>Unzip the package i.e. <em>dummy_Theme </em>into the themes/ folder of your dev site. </p>
<p>Go to your dev site&#8217;s dashboard, the new theme should appear as one of the available templates.</p>
<p>Make changes, i.e. change the logo (which can be found in the images/ folder of the theme).</p>
<p>In Dreamweaver, right-click on your chosen theme, theme/<em>dummy_Theme  </em>and click Put. This will automatically upload the folder in your live site.</p>
<p>Go to your remote site&#8217;s dashboard, the new theme should appear as one of the available templates.</p>
<p><strong>References</strong></p>
<p><a href="http://codex.wordpress.org/Main_Page">http://codex.wordpress.org/Main_Page</a> - wordpress guide</p>
<p><a href="http://codex.wordpress.org/Installing_WordPress#Detailed_Instructions">http://codex.wordpress.org/Installing_WordPress#Detailed_Instructions</a> - detailed installation&#8217;s instructions</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/webwok.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/webwok.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=58&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/08/01/dev-live-wordpress-site/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
	</channel>
</rss>