<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Web wok &#187; projects</title>
	<atom:link href="http://webwok.wordpress.com/category/projects/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 &#187; projects</title>
		<link>http://webwok.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://webwok.wordpress.com/osd.xml" title="Web wok" />
		<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>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>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>
		<item>
		<title>Photoalbum with Flickr &#8211; part 1 testing the API</title>
		<link>http://webwok.wordpress.com/2008/07/29/photoalbum-with-flickr-part-1-testing-the-api/</link>
		<comments>http://webwok.wordpress.com/2008/07/29/photoalbum-with-flickr-part-1-testing-the-api/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 12:42:12 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[MyHouseMyStreet]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[photoalbum]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=51</guid>
		<description><![CDATA[The aim
I wanted to have a photoalbum for the buildings and the people who lived in a street. However, I wanted the photoalbum to be as shareable and robust as possible. Thus, instead of building my own, I opted for using Flickr.
Apart from the fact that Flickr is possibly the most popular photosharing network, it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=51&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>The aim</h2>
<p>I wanted to have a photoalbum for the buildings and the people who lived in a street. However, I wanted the photoalbum to be as shareable and robust as possible. Thus, instead of building my own, I opted for using Flickr.</p>
<p>Apart from the fact that Flickr is possibly the most popular photosharing network, it has also the great advantage of offering an API which allows seamless integration with your applications. Furthermore, lots of people are contributing to create wrappers on different languages which simplify the API calls.</p>
<p>On this regard, since the project is written in PHP, I decided to adopt phpFlickr for my purposes. At the time of this post, the version is 2.2.0.</p>
<h2>Run a preliminary test</h2>
<p>The first step was to get the API key . This is free and you can obtain it by logging into your Flickr&#8217;s account and clicking on: http://www.flickr.com/services/api/keys/</p>
<p>Once you have completed the registration process, you will be given two codes, which you will need later to access Flickr, an api key and a secret.</p>
<p>I always do my experiments in a local website, which acts like a sandbox (&#8220;tests&#8221;) for my experiments so that I do damage my actual applications.  Thus to test Flickr API, I have created a subfolder &#8220;flickrapi&#8221; in my tests folder. I have also created an empty file index.php and checked the server sees the new folder:</p>
<p>localhost:8020/flickapi (where localhost:8020/ is my virtual host for the tests folder in Apache)</p>
<p>Next, I have downloaded phpFlickr in the &#8220;flickrapi&#8221; folder.</p>
<p>To check that the package is seen by php,  I have modified flickrapi/index.php with:</p>
<pre>&lt;?
include "phpFlickr/phpFlickr.php";
?&gt;</pre>
<p>If no errors are displayed, the package has successfully accessed.</p>
<p>The second step was to start using the API itself.  phpFlickr implements all the API methods as methods of a Flickr class. So you need to instantiate a Flickr object first, by doing:</p>
<p>$f = new phpFlickr($api_key,$secret,$die_on_error);</p>
<p>where:</p>
<p>$api_key and $secret &#8211; are the API key and secret code obtained earlier.</p>
<p>$die_on_error &#8211; is a boolean value and determines whether operations should cease if the API returns an error (default is false).</p>
<p>If no error occurred, you can start quering Flickr using the specified methods on $f ( these are defined in phpFilckr.php).</p>
<p>Since the test was successful, I moved on to play a bit with Flickr&#8217;s calls. In particular I wanted to:</p>
<p>1. access my photos</p>
<p>2. retrieve pictures according to their tags and machine tags</p>
<h3>access to my photos</h3>
<p>First, I searched among the people&#8217;s database on Flickr, my own account. Then, from my account&#8217;s details, I retrieved my user id and using this I got access to my photos.</p>
<pre>$username="myusername_example";
  // Find the NSID of the username inputted via the form
    $person = $f-&gt;people_findByUsername($username);

    // Get the friendly URL of the user's photos
    $photos_url = $f-&gt;urls_getUserPhotos($person['id']);</pre>
<h3>get photos with specific tags and machine tags</h3>
<p>To run a search, I used <a href="http://www.flickr.com/services/api/flickr.photos.search.html" target="_blank">photos_search method </a> and as the $tags variable I specified the tags/machine tags I wanted to filter my photos by.</p>
<pre>//Get photos that have tag "flat"
$photos =$f-&gt;photos_search(array("user_id"=&gt;$person['id'],
"tags"=&gt;"flat",
"per_page"=&gt;6));
//Get photos with machine tag building num 2, which represents a building number.
      $photos =$f-&gt;photos_search(array("user_id"=&gt;$person['id'], "machine_tags"=&gt;"myhousemystreet:buildingnum=\"2\"", "per_page"=&gt;6));</pre>
<p>The last <strong>(optional)</strong> step  for me was to move the phpFlickr package from my  test folder &#8220;flickrapi&#8221; to the folder which contains all my php packages, in my PHP5 installation. Then, I had to modify my code accordingly to check it still worked. This final test allowed me to see that I can now use phpFlickr in any site I want from now on, by just inserting:</p>
<pre>require_once incpath("/phpFlickr/phpFlickr.php");</pre>
<p>At the top of my php files. This is an optional step, but if I didn&#8217;t do that, every time I needed to use Flickr API, I would have had to copy phpFlickr as a folder within my new website.</p>
<p>So here&#8217;s my final index.php:</p>
<pre>&lt;?
/**
 * Testing connection to Flickr, using API.
 * inspired by http://phpflickr.com/
*/
require_once incpath("/phpFlickr/phpFlickr.php");

$api_key ="c0fde778bd98ac8701f2d4e8ef0be50c";
$secret ="dcf4ae887a9b1a06";
$die_on_error =true;// cease operation) if the API returns an error statement
$f = new phpFlickr($api_key,$secret,$die_on_error);
//SEARCH FOR PHOTOS
$username="val.cartei";
  // Find the NSID of the username inputted via the form
    $person = $f-&gt;people_findByUsername($username);

    // Get the friendly URL of the user's photos
    $photos_url = $f-&gt;urls_getUserPhotos($person['id']);

	//Get first 10 photos with specified tag in $extras
	  $photos =$f-&gt;photos_search(array("user_id"=&gt;$person['id'], "machine_tags"=&gt;"myhousemystreet:bnum=\"2\"", "per_page"=&gt;6));
/*
    // Get the user's first 10 public photos
    $photos = $f-&gt;people_getPublicPhotos($person['id'], NULL, 10);
*/
	$i=0;
	  // Loop through the photos and output the html
    foreach ((array)$photos['photo'] as $photo) {
        echo "&lt;a href=$photos_url$photo[id]&gt;";
        echo "&lt;img border='0' alt='$photo[title]' ".
            "src=" . $f-&gt;buildPhotoURL($photo, "Square") . "&gt;";
        echo "&lt;/a&gt;";
        $i++;
        // If it reaches the sixth photo, insert a line break
        if ($i % 6 == 0) {
            echo "&lt;br&gt;\n";
        }
	}

?&gt;</pre>
<h2>Resources</h2>
<p>http://www.flickr.com/services/api/ &#8211; Flickr&#8217;s API Official Documentation</p>
<p>http://phpflickr.com/ &#8211; the official website for the phpFlickr package.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/webwok.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/webwok.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=51&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/07/29/photoalbum-with-flickr-part-1-testing-the-api/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>
	</channel>
</rss>