<?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/"
	>

<channel>
	<title>Web design and development in London and Surrey &#187; Tutorials</title>
	<atom:link href="http://zorinweb.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://zorinweb.com</link>
	<description>Just another Web design and development weblog</description>
	<lastBuildDate>Fri, 13 Jan 2012 14:56:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Converting a Design to a WordPress Website</title>
		<link>http://zorinweb.com/2009/12/converting-a-design-to-a-wordpress-website/</link>
		<comments>http://zorinweb.com/2009/12/converting-a-design-to-a-wordpress-website/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 19:09:22 +0000</pubDate>
		<dc:creator>ZorinWeb</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[psd to html]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://zorinweb.com/?p=103</guid>
		<description><![CDATA[There doesn&#8217;t appear to be too many psd to HTML tutorials on the net, so I thought I&#8217;d write one. Given the popularity of the WordPress blogging software, I&#8217;ll code the design up for WordPress rather than a static HTML site.  To reiterate, this is about taking a design (in whatever format), slicing it up [...]]]></description>
			<content:encoded><![CDATA[<p>There doesn&#8217;t appear to be too many psd to HTML tutorials on the net, so I thought I&#8217;d write one. Given the popularity of the WordPress blogging software, I&#8217;ll code the design up for WordPress rather than a static HTML site.  To reiterate, this is about taking a design (in whatever format), slicing it up in Photoshop, or similar (Gimp), then applying the CSS to the HTML. WordPress features intuitive markup, so I&#8217;ll base the HTML around theirs.</p>
<p><span id="more-103"></span></p>
<p>The slicing of the design will be dealt with first, followed by a look at the HTML, then proceeded by the all important CSS. To begin with, let&#8217;s look at the design in the slicing environment.</p>
<p><img class="alignnone size-large wp-image-107" title="1-overview" src="http://zorinweb.com/wp-content/uploads/2009/12/1-overview-440x255.jpg" alt="1-overview" width="440" height="255" /></p>
<p>This is the psd of a recently completed website opened up and ready to slice in Photoshop. It&#8217;s a clean, uncomplicated design, so should be ideal for a tutorial. For demonstration purposes, I&#8217;m using the &#8216;crop&#8217; tool instead of slicing tool, and saving each piece as a jpg in turn. There&#8217;s not a particular preference for image formt, so use what you wish; jpgs load up quicky, that&#8217;s all. Right, let the cutting begin.</p>
<p><img class="alignnone size-large wp-image-112" title="background-slice" src="http://zorinweb.com/wp-content/uploads/2009/12/background-slice-440x123.jpg" alt="background-slice" width="440" height="123" /></p>
<p>A slice is taken from the top of the psd going through the white space to just below the thick green line. It will be repeated across the &lt;body&gt; of the document, covering the width of the screen. Next, the little house with the lightbulb is cut out.</p>
<p><img class="alignnone size-large wp-image-116" title="cutting-out-the-little-hous" src="http://zorinweb.com/wp-content/uploads/2009/12/cutting-out-the-little-hous-440x113.jpg" alt="cutting-out-the-little-hous" width="440" height="113" /></p>
<p>The house is cut out from the top to just beneath the green like. It will later be layered over repeated background strip. Now for the logo and introductory text.</p>
<p><a href="http://zorinweb.com/wp-content/uploads/2009/12/cutting-out-the-logo.jpg"><img class="alignnone size-large wp-image-118" title="cutting-out-the-logo" src="http://zorinweb.com/wp-content/uploads/2009/12/cutting-out-the-logo-440x141.jpg" alt="cutting-out-the-logo" width="440" height="141" /></a></p>
<p><img class="alignnone size-large wp-image-117" title="cutting-out-logo" src="http://zorinweb.com/wp-content/uploads/2009/12/cutting-out-logo-440x113.jpg" alt="cutting-out-logo" width="440" height="113" /></p>
<p>A similar effect for the text could have been gained using sIFR, but on this occassion opted for a CSS text replacement technique. After cutting out the navigation buttons &#8211; both the blue and &#8216;hover effect&#8217; orange &#8211; and other bits and pieces, the last substantial piece of cutting is the Twitter section.</p>
<p><img class="alignnone size-large wp-image-119" title="cutting-out-twitter" src="http://zorinweb.com/wp-content/uploads/2009/12/cutting-out-twitter-bird-440x113.jpg" alt="cutting-out-twitter" width="440" height="113" /></p>
<p>That&#8217;s all the cutting; let&#8217;s run through the pieces.</p>
<ul>
<li>Background strip</li>
<li>Logo</li>
<li>Introductory text</li>
<li>House with lightbulb</li>
<li>Navigation buttons</li>
<li>Twitter section</li>
<li>Twitter button</li>
<li>Contact and Twitter headings</li>
</ul>
<h3>The HTML</h3>
<p>Assuming you&#8217;ve installed a copy of WordPress, let&#8217;s navigate to the default theme to inspect the markup &#8211; <em>&#8216;wp-content&#8217;, &#8216;themes&#8217;, &#8216;default&#8217;</em> directory. Open the index.php to view the following:<br />
<code><br />
&lt;?php<br />
/**<br />
* @package WordPress<br />
* @subpackage Default_Theme<br />
*/<br />
get_header(); ?&gt;<br />
&lt;div id="content" role="main"&gt;<br />
<strong>&lt;?php if (have_posts()) : ?&gt;<br />
&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
&lt;div &lt;?php post_class() ?&gt; id="post-&lt;?php the_ID(); ?&gt;"&gt;<br />
&lt;h2&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;<br />
&lt;small&gt;&lt;?php the_time('F jS, Y') ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;&lt;/small&gt;<br />
&lt;div&gt;<br />
&lt;?php the_content('Read the rest of this entry &amp;raquo;'); ?&gt;<br />
&lt;/div&gt;<br />
&lt;p&gt;&lt;?php the_tags('Tags: ', ', ', '&lt;br /&gt;'); ?&gt; Posted in &lt;?php the_category(', ') ?&gt; | &lt;?php edit_post_link('Edit', '', ' | '); ?&gt;  &lt;?php comments_popup_link('No Comments &amp;#187;', '1 Comment &amp;#187;', '% Comments &amp;#187;'); ?&gt;&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;?php endwhile; ?&gt;<br />
&lt;div&gt;<br />
&lt;div&gt;&lt;?php next_posts_link('&amp;laquo; Older Entries') ?&gt;&lt;/div&gt;<br />
&lt;div&gt;&lt;?php previous_posts_link('Newer Entries &amp;raquo;') ?&gt;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;?php else : ?&gt;<br />
&lt;h2&gt;Not Found&lt;/h2&gt;<br />
&lt;p&gt;Sorry, but you are looking for something that isn't here.&lt;/p&gt;<br />
&lt;?php get_search_form(); ?&gt;<br />
&lt;?php endif; ?&gt;</strong><br />
&lt;/div&gt;<br />
&lt;?php get_sidebar(); ?&gt;<br />
&lt;?php get_footer(); ?&gt;</code></p>
<p>The WordPress loop, in bold, doesn&#8217;t have any bearing on this tutorial, so we can ignore it. get_header() renders the header part of the HTML, while get_sidebar() and get_footer() render the sidebar and footer, respectively. I&#8217;ve gone through the index.php file to avoid confusion; what I&#8217;d like to do is go through the rendered HTML as that&#8217;s what we&#8217;re going to style. Here&#8217;s the rendered HTML of index.php without the PHP &#8216;loop&#8217; (I&#8217;ve deleted a few unordered lists fro the sidebar as they&#8217;re not relevant):<br />
<code><br />
&lt;body&gt;<br />
&lt;div id="page"&gt;<br />
&lt;div id="header" role="banner"&gt;<br />
&lt;div id="headerimg"&gt;&lt;h1&gt;&lt;a href="Blog name"&lt;/a&gt;&lt;/h1&gt;<br />
&lt;div&gt;&lt;?php bloginfo('description'); ?&gt;&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;hr /&gt;<br />
&lt;div id="content" role="main"&gt;<br />
&lt;/div&gt;<br />
&lt;div id="sidebar" role="complementary"&gt;<br />
&lt;ul role="navigation"&gt;<br />
&lt;li&gt;&lt;h2&gt;Archives&lt;/h2&gt;&lt;/ul&gt;&lt;/li&gt;<br />
&lt;ul&gt;&lt;li&gt;&lt;h2&gt;Meta&lt;/h2&gt;&lt;/li&gt;&lt;/ul&gt;<br />
&lt;/div&gt;<br />
&lt;hr /&gt;<br />
&lt;div id="footer" role="contentinfo"&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
</code><br />
Minus a few unordered listed from the sidebar, the above is more or less the standard HTML from the default theme. The site we&#8217;re working on in this tutorial is customised, so has slightly different HTML, but importantly, a similar structure. Here&#8217;s the HTML from DRC Electrical:<br />
<code><br />
&lt;body&gt;<br />
&lt;div id="page"&gt;<br />
&lt;div id="header"&gt;<br />
&lt;h1&gt;&lt;a href="http://drcelectrical.co.uk/" onfocus="if (this.blur)this.blur();"&gt;&lt;span&gt;DRC Electrical Services&lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;<br />
&lt;ul id="nav"&gt;<br />
&lt;li&gt;&lt;a href="http://drcelectrical.co.uk/" onfocus="if (this.blur)this.blur();"&gt;Home&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="/services/" onfocus="if (this.blur)this.blur();"&gt;Services&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="/testimonials/" onfocus="if (this.blur)this.blur();"&gt;testimonials&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="/blog/" onfocus="if (this.blur)this.blur();"&gt;blog&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="/contact/" onfocus="if (this.blur)this.blur();"&gt;contact&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;div&gt;&lt;span&gt;Hello, we are a company offering electrical services&lt;/span&gt;&lt;/div&gt;<br />
&lt;div&gt;&lt;/div&gt;<br />
&lt;/div&gt;&lt;!--end of header--&gt;<br />
&lt;div id="content"&gt;<br />
&lt;div id="sidebar"&gt;<br />
&lt;div&gt;<br />
&lt;div&gt;<br />
&lt;h1&gt;&lt;span&gt;Contact DRC Electrical&lt;/span&gt;&lt;/h1&gt;<br />
&lt;p&gt;We always like to talk to people.<br />
Just drop us an email or call us.&lt;/p&gt;<br />
&lt;div&gt;020 8287 7907&lt;/div&gt;<br />
&lt;p&gt;Mobile:&lt;/p&gt;<br />
&lt;div&gt;07985 279916&lt;/div&gt;<br />
&lt;p&gt;Email:&lt;/p&gt;<br />
&lt;div&gt;info@drcelectrical.co.uk&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;div&gt;<br />
&lt;h1&gt;&lt;span&gt;Twitter&lt;/span&gt;&lt;/h1&gt;<br />
&lt;div&gt;<br />
Going to elex expo at sandown should be good &lt;a href="http://twitter.com/DRC_Electrical/statuses/6218208623" class="twitter-link"&gt;Go&lt;/a&gt; &lt;span class="twitter-timestamp"&gt;&lt;abbr title="2009/12/01 00:24:04"&gt;2009/12/01&lt;/abbr&gt;&lt;/span&gt;<br />
&lt;/div&gt; &lt;!--end of twitter-message--&gt;<br />
&lt;a href="http://twitter.com/DRC_Electrical/"&gt;&lt;/a&gt;<br />
&lt;/div&gt;&lt;!--end of Twitter-div--&gt;<br />
&lt;ul&gt;&lt;li&gt;<br />
&lt;/ul&gt;<br />
&lt;/div&gt;&lt;!--end of sidebar-content--&gt;<br />
&lt;/div&gt;&lt;!--end of sidebar--&gt;<br />
&lt;div id="content-left"&gt;&lt;!--post/content goes in here--&gt;<br />
&lt;div id="post-3"&gt;<br />
&lt;h2&gt;DRC Electrical….&lt;/h2&gt;<br />
&lt;div&gt;<br />
&lt;p&gt;provide electrical services to the London and Surrey areas. Fully qualified, and with years of experience on hand, our typical jobs range from electrical testing to full rewires. Emergency callouts, or jobs booked well in advance, we cover them all.&lt;/p&gt;<br />
&lt;p&gt;Our work is balanced between domestic and corporate customers alike. Onsite commercial electrical work is an area we’re very familiar with. From quotation to completion, we handle everything including sourcing products to disposal.&lt;/p&gt;<br />
&lt;p&gt;If you’re after a competitive rate from an company that’ll provide peace of mind, please don’t hesitate to get in touch. For emails, we aim to respond within 12-hours, while for enquiries that need immediate attention, please telephone.&lt;/p&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;&lt;!--end of post--&gt;<br />
&lt;/div&gt;&lt;!--end of content-left--&gt;<br />
&lt;/div&gt;&lt;!--end of content--&gt;<br />
&lt;div id="footer"&gt;<br />
&lt;div&gt;&lt;a href="http://www.zorinweb.com" target='blank' title="Website by Zw"&gt;Site by Zw&lt;/a&gt;&lt;/div&gt;<br />
&lt;div&gt;&amp;copy; 2009 DRC Electrical&lt;/div&gt;<br />
&lt;/div&gt;&lt;!--end of footer--&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
</code><br />
That&#8217;s the generated HTML from the home page which I&#8217;ve commented as best as possible. The structure&#8217;s very similar to the default theme; we still have the &#8216;page&#8217; DIV, &#8216;header&#8217;, &#8216;content&#8217;, &#8216;sidebar&#8217; and &#8216;footer&#8217;. Assuming you&#8217;ve cut out the images, place them in an appropriate folder, and set up the development environment (if you use one), and let&#8217;s begin the styling.</p>
<h3>The CSS</h3>
<p>First, the body:<br />
<code><br />
body {<br />
margin: 0;<br />
padding: 0;<br />
font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;<br />
font-size: 13px;<br />
color: #fff;<br />
height: 100%;<br />
background: #1479c7 url(images/background-repeat.jpg) repeat-x;<br />
}<br />
</code><br />
Importantly here, we&#8217;ve taken our initial bit of slicing, &#8216;background-repeat.jpg&#8217;, and repeated it across the body&#8217;s x axis, and set the background to #1479c7. That&#8217;s the top of the sorted out, margin and padding zeroed in, etc.. As for the structure:<br />
<code><br />
#page {<br />
width: 810px;<br />
margin: 0 auto;<br />
}<br />
</code><br />
The outer DIV, page, is set to 810px wide and placed in the centre.<br />
<code><br />
#header {<br />
width: 810px;<br />
height: 380px;<br />
position: relative;<br />
}<br />
</code><br />
With the header&#8217;s styling in place, we can now plonk the logo, navigation and introductory sentence in.<br />
<code><br />
#header h1 {<br />
margin:0px;<br />
font-weight:bold;<br />
}<br />
#header h1 a {<br />
height:100px;<br />
width:350px;<br />
background: url(images/logo.jpg) no-repeat 0px 10px;<br />
float:left;<br />
margin:20px 0 0 0;<br />
}<br />
#header h1 a span {<br />
display: none;<br />
}<br />
</code><br />
Adhering to best practices and accessibility, the logo&#8217;s attached to a link within an H1 one heading. The actual HTML for DRC Electrical is inserted between span tags set to &#8216;display: none&#8217;. Here&#8217;s the navigation&#8217;s CSS:<br />
<code><br />
#nav {<br />
width: 800px;<br />
position: relative;<br />
padding: 3px;<br />
margin: 0 0 0 7px;<br />
height: 30px;<br />
float: left;<br />
font-weight: bold;<br />
font-family: Georgia, "Times New Roman", Times, serif;<br />
}<br />
#nav li {<br />
width: 120px;<br />
float: left;<br />
list-style: none;<br />
}<br />
#nav a {<br />
height: 26px;<br />
color: #FFF;<br />
display: block;<br />
text-decoration: none;<br />
text-align: center;<br />
background: url(images/nav-button.jpg) no-repeat;<br />
padding: 4px 0 0 0;<br />
}<br />
#nav a:hover {<br />
background: url(images/nav-button-hover.jpg) no-repeat;<br />
}<br />
</code><br />
&#8216;#nav&#8217; sets the container&#8217;s dimensions, &#8216;#nav li&#8217; sorts out the individual elements, while &#8216;#nav a&#8217; style&#8217;s out the actual links assigning the background of each to &#8216;images/nav-button.jpg&#8217;, the blue button cut out earlier on. Lastly for the navigation, &#8216;#nav a:hover&#8217; gives a nice little hover effect with the orange button, &#8216;nav-button-hover.jpg&#8217;.</p>
<p>The introductory sentence is encased within &#8216;hello&#8217; DIV.<br />
<code><br />
.hello {<br />
background: url(images/intro-text.jpg) no-repeat;<br />
float: left;<br />
height: 140px;<br />
margin: 30px 0 0;<br />
width: 470px;<br />
}<br />
.hello span {<br />
display: none;<br />
}<br />
</code><br />
Again, the background&#8217;s set to images/intro-text.jpg, with a span styled to display none for the HTML to make it accessible. Closing out the header section, a DIV with a class of &#8216;lamp&#8217;. The following should be self explanatory:<br />
<code><br />
.lamp {<br />
float: right;<br />
height: 200px;<br />
margin: 16px 70px 0 0;<br />
width: 230px;<br />
background: url(images/lightbulb4.jpg) no-repeat;<br />
}<br />
</code><br />
Moving onto the &#8216;content&#8217; portion:<br />
<code><br />
#content {<br />
width: 810px;<br />
float :left;<br />
}<br />
#content-left {<br />
width: 530px;<br />
min-height: 650px;<br />
position: relative;<br />
float: left;<br />
}<br />
</code><br />
&#8216;content-left&#8217; is simply floated to the left to make way for the sidebar which appears before &#8216;content-left&#8217; in the markup. Here&#8217;s the sidebar and it&#8217;s paragraph element:<br />
<code><br />
#sidebar {<br />
margin: 0 0 0 6px;<br />
min-height: 600px;<br />
width: 258px;<br />
float: right;<br />
display: table;<br />
}<br />
#sidebar p {<br />
margin:4px 0;<br />
color:#B8B291;<br />
width:220px;<br />
}<br />
</code><br />
Incidentally display is set to &#8216;table&#8217;; I&#8217;ll explain about that in another tutorial. The next DIV in the sidebar is &#8216;side-content&#8217;.<br />
<code><br />
.side-content {<br />
float: left;<br />
width: 258px;<br />
padding: 0;<br />
min-height: 500px;<br />
}<br />
</code><br />
The first piece of content in the sidebar deals with contact details, which is inserted in:<br />
<code><br />
.contact {<br />
border-bottom: 1px #7ab3df solid;<br />
}<br />
</code><br />
This gives us a nice border at the bottom.<br />
<code><br />
h1.contact-sidebar  {<br />
width: 226px;<br />
height: 38px;<br />
background: url(images/sidebar-contact.jpg) no-repeat -6px 0;<br />
margin: 0;<br />
}<br />
h1.contact-sidebar span {<br />
display: none;<br />
}<br />
</code><br />
The above styling&#8217;s for the &#8216;contact&#8217; heading. sidebar-contact.jpg is cut out of the psd and assigned to an H1 heading with a class of .contact-sidebar. The same applies to the Twitter heading.<br />
<code><br />
h1.twitter-sidebar  {<br />
width: 226px;<br />
height:38px;<br />
background: url(images/sidebar-twitter.jpg) no-repeat -6px 0;<br />
margin:0;<br />
}<br />
h1.twitter-sidebar span {<br />
display:none;<br />
}<br />
</code><br />
Finishing off the sidebar is Twitter feed box and the corresponding &#8216;follow me&#8217; button:<br />
<code><br />
.twitter-div {<br />
background:transparent url(images/twitter-box.jpg) no-repeat -10px 55px;<br />
border-bottom:1px solid #7ab3df;<br />
height:205px;<br />
padding:10px 0;<br />
}<br />
.twitter-message {<br />
color:#B8B291;<br />
margin:18px 0 0 8px;<br />
padding:0;<br />
width:240px;<br />
height:82px;<br />
}<br />
.followme {<br />
background:url(images/follow-me-button.jpg) no-repeat;<br />
display:block;<br />
margin-top:25px;<br />
height:30px;<br />
width:145px;<br />
}<br />
</code><br />
The .twitter-div has it&#8217;s background set to  url(images/twitter-box.jpg) no-repeat -10px 55px; this is the Twitter box cut out earlier on. The &#8216;twitter-message&#8217; fits in the box and styles the input, while &#8216;follow me&#8217; button has it&#8217;s background set appropriately.</p>
<p>That takes care of all the images; here&#8217;s the rest of the CSS to go with the remaining markup:<br />
<code><br />
#footer {<br />
float:left;<br />
height:39px;<br />
padding:40px 0 0;<br />
width: 810px;<br />
color:#7ab3df;<br />
}<br />
</code><br />
Hope you enjoyed the tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://zorinweb.com/2009/12/converting-a-design-to-a-wordpress-website/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Simple jQuery Drop Down Menu</title>
		<link>http://zorinweb.com/2009/12/simple-jquery-drop-down-menu/</link>
		<comments>http://zorinweb.com/2009/12/simple-jquery-drop-down-menu/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 21:16:46 +0000</pubDate>
		<dc:creator>ZorinWeb</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://zorinweb.com/?p=86</guid>
		<description><![CDATA[Jquery&#8217;s a phenomenal JavaScript library that greatly reduces the amount of JavaScript required for front-end user interface interactions and utility tasks. As a quick introduction to the wonders of jQuery, I&#8217;ll demonstrate how simple it is to build a dropdown menu. First off, the HTML: &#60;div id="page"&#62; &#60;div id="content"&#62; &#60;ul id="menu"&#62; &#60;li&#62;&#60;a href="#"&#62;About Us&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a [...]]]></description>
			<content:encoded><![CDATA[<p>Jquery&#8217;s a phenomenal JavaScript library that greatly reduces the amount of JavaScript required for front-end user interface interactions and utility tasks. As a quick introduction to the wonders of jQuery, I&#8217;ll demonstrate how simple it is to build a dropdown menu. First off, the HTML:<br />
<code><br />
&lt;div id="page"&gt;<br />
&lt;div id="content"&gt;<br />
&lt;ul id="menu"&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;About Us&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#" id="show"&gt;Services&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;ul id="service-options"&gt;<br />
&lt;li&gt;&lt;a href="blinds.html"&gt;Products&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="curtains.html"&gt;Testimonials&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="interior-designs.html"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;ul id="menu"&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;Products&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;Testimonials&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&gt;&lt;a href="#"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;&lt;!--page ends--&gt;</code></p>
<p><span id="more-86"></span></p>
<p>We have a horizontal menu with a fitting ID of &#8216;menu&#8217;, nestled in a &#8216;content&#8217; DIV. Within the menu there&#8217;s a DIV named &#8216;service-options&#8217; which is a sub menu of &#8216;services&#8217;. Unordered list &#8216;service-options&#8217; is hidden and only drops down upon clicking the &#8216;services&#8217; link. Now for the JavaScript:<br />
<code><br />
&lt;script type="text/javascript"&gt;<br />
$(document).ready(function() {<br />
// hides the sub menu as soon as the DOM is ready, just before page load)<br />
$('#service-options').hide();<br />
// shows sub menu, service-options, when clicking the 'services' link<br />
$('a#show').click(function() {<br />
$('#service-options').toggle('slow');<br />
return false;<br />
});<br />
});<br />
&lt;/script&gt;</code></p>
<p>Looking at the JavaScript, as soon as the DOM&#8217;s ready (once the browser&#8217;s reviewed the HTML), the &#8216;service-options&#8217;<br />
ul is hidden using jQuery&#8217;s .hide() method. Next, an event handler is assigned to the &#8216;services&#8217; link which has an ID of &#8216;#show&#8217;.  $(&#8216;#service-options&#8217;).toggle(&#8216;slow&#8217;) attachs the &#8216;toggle&#8217; method to the sub menu; this toggles it between two states, hidden and not hidden (not hidden being jQuery&#8217;s show() method). Incidentally, $(&#8216;#service-options&#8217;) is jQuery&#8217;s method of selecting an element.  That&#8217;s it, the event has been assigned to the &#8216;services&#8217; link ready to toggle the sub menu in and out of view.</p>
<p><a href='http://zorinweb.com/wp-content/uploads/2009/12/dropdown-menu.txt'>Download the file</a> to play around with the script. Of course, you&#8217;ll need the <a href="http://jquery.com/">jQuery</a> library.</p>
]]></content:encoded>
			<wfw:commentRss>http://zorinweb.com/2009/12/simple-jquery-drop-down-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the Flickr API to Import Images to your Website</title>
		<link>http://zorinweb.com/2009/12/using-the-flickr-api-to-import-images-to-your-website/</link>
		<comments>http://zorinweb.com/2009/12/using-the-flickr-api-to-import-images-to-your-website/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 20:27:49 +0000</pubDate>
		<dc:creator>ZorinWeb</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://localhost/zorin-wordpress/?p=55</guid>
		<description><![CDATA[With a vast number of WordPress plugins available, it&#8217;s easy to download one, then plug and play while not having to get involved with any code. Although convenient, sometimes it&#8217;s intersting to know what&#8217;s going on under the bonnet. Here, I&#8217;ll be looking at the Flickr API thanks in large part to an interesting chapter [...]]]></description>
			<content:encoded><![CDATA[<p>With a vast number of WordPress plugins available, it&#8217;s easy to download one, then plug and play while not having to get involved with any code. Although convenient,  sometimes it&#8217;s intersting to know what&#8217;s going on under the bonnet. Here, I&#8217;ll be looking at the Flickr API thanks in large part to an interesting chapter from Sitepoint&#8217;s &#8216;The Art and Science of Javascript&#8217;. Where they mashed up Flickr with Google maps, I&#8217;ll merely download a Flickr gallery to a site, integrating it with the famous &#8216;lightbox&#8217; image viewer so users can view an enlarged images without having to go to Flickr.</p>
<p><span id="more-55"></span></p>
<p>Assuming you have a Flickr account complete with images, you&#8217;ll need to retrieve your Flickr ID. Log into profile and look at the URL; for me it&#8217;s this one:</p>
<p><code><a href="http://www.flickr.com/photos/36013535@N03/">http://www.flickr.com/photos/36013535@N03/</a></code></p>
<p>The user ID is the group of characters following the end slash after &#8216;photos&#8217;. With that copy and pasted, it&#8217;s time to insert it into the Flickr API URL:</p>
<p><code>&lt;script type="text/javascript" src="<a href="http://api.flickr.com/services/feeds/photos_public.gne?id=">http://api.flickr.com/services/feeds/photos_public.gne?id=</a><strong>36013535@N03</strong>&amp;lang=en-us&amp;format=json"&gt;</code></p>
<p>If an RSS feed was required, we&#8217;d substitute the &#8216;format=json&#8217; for &#8216;format=rss_200, but in this case it isn&#8217;t. Once load, the JSON (Javascript Object Notation) object (the feed returned from Flickr the account) is assigned to a global variable by way of the following callback function:</p>
<p><code>function jsonFlickrFeed(json) {<br />
// Assign to a global variable<br />
window.jsonFromFlickr = json;<br />
}<br />
</code></p>
<p>Where the window.jsonFromFlickr gives the data global scope (as an aside and beyond the scope of this tutorial, the jsonFlickrFeed function is defined to avoid the cross domain restriction problem <a href="http://en.wikipedia.org/wiki/Same_origin_policy">http://en.wikipedia.org/wiki/Same_origin_policy</a>). To recap, once the data is loaded, it&#8217;s assigned to a function which stores the output in a global variable for later manipulation, and follows courtesy of the following two functions:<br />
<code><br />
function makePhoto(photo) {<br />
var li = document.createElement('li');<br />
var a = document.createElement('a');<br />
a.href = photo.link;<br />
a.target = "_blank";<br />
var img = document.createElement('img');<br />
img.src = photo.media.m.replace('_m', '_s');<br />
img.title = photo.title;<br />
img.alt = photo.alt;<br />
a.appendChild(img);<br />
li.appendChild(a);<br />
return li;<br />
}<br />
</code><br />
<code><br />
function showPhotos() {<br />
if (!jsonFromFlickr) {<br />
alert('Flickr photos failed to load');<br />
}<br />
// 'Empty' the ul by removing all of its children<br />
var ul = document.getElementById('myPhotos');<br />
while (ul.hasChildNodes()) {<br />
ul.removeChild(ul.firstChild);<br />
}<br />
// Loop over the photos and display them all<br />
for (var i = 0; i &lt;= 9; i++) {<br />
photo = jsonFromFlickr.items[i];<br />
ul.appendChild(makePhoto(photo));<br />
}<br />
}<br />
</code><br />
<code><br />
window.onload = showPhotos;<br />
</code><br />
<code><br />
&lt;!--HTML that's inserted within the body tags and renders the gallery--&gt;<br />
&lt;ul id="myPhotos"&gt;<br />
&lt;li&gt;&lt;a href="http://www.flickr.com/photos/myFlickrID/"&gt;ZorinWeb's Flickr Gallery&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
</code><br />
The first one, makePhoto(photo), is more or less a utility function used to construct the HTML from the JSON, triggered by the second  function,showPhotos(). Firstly,  showPhotos(), executed upon page load, checks to see if the global variable is present; if not, an alert box is thrown. Next, the function navigates the DOM to find the myPhotos &lt;ul&gt; node (this is where the images will rendered, in an unordered list) and remove the child nodes ready for re-population. Finally, showPhotos() loops over the JSON feed to generate the gallery in an unordered list. In the loop, variable &#8216;photo&#8217; is assigned  ith item from the feed, which is passed to the makePhoto() function. When returned as an &lt;li&gt; element, DOM method &#8216;appendChild&#8217; is used to populate the unordered list.</p>
<p>Function makePhoto(photo) is quite self explanatory; an &lt;li&gt; is generated, before the hyperlink from the JSON feed (photo.link) is assigned to the newly created a.href. For img.src. &#8216;photo.media.m.replace&#8217; replaces the &#8216;_m&#8217; with an &#8216;_s&#8217; in the src string to get a 75 * 75 pixel thumbnail. Title and alt attributes are built into the image which is then appended to the link. Lastly, the link is embedded within the list item before being returned to theshowPhotos() function. The showPhotos() loop completes leaving the &lt;ul&gt; populated on the page.</p>
<p>The thumbnails are now on the page, but in its present state can&#8217;t use the Lighbox gallery. When clicked, the user will be taken to Flickr which isn&#8217;t the idea; we want them to remain on the site, hence using Lightbox, or any other Lightbox effect. To achieve this, themakePhoto(photo) function is amended as follows:<br />
<code><br />
function makePhoto(photo) {<br />
var li = document.createElement('li');<br />
var a = document.createElement('a');<br />
//a.href = photo.link;<br />
a.href = photo.media.m.replace('_m', '');<br />
a.rel = 'lightbox[Zorin]';<br />
a.title = photo.title;<br />
var img = document.createElement('img');<br />
img.src = photo.media.m.replace('_m', '_s');<br />
img.title = photo.title;<br />
img.alt = photo.alt;<br />
a.appendChild(img);<br />
li.appendChild(a);<br />
return li;<br />
}<br />
</code><br />
The a.href is replaced with the link of the actual image (with neither the _m or _s, just the full size image) as opposed to the page. Furthermore, to make Lightbox function, a.rel has been added in and set to &#8216;lightbox[Zorin]&#8216;; &#8216;Zorin&#8217; has been included to allow navigation through a gallery within Lightbox. That&#8217;s it; here&#8217;s how the code should appear in the &lt;head&gt; of the document:<br />
<code><br />
<!--CSS file for Lightbox--><br />
&lt;head&gt;<br />
&lt;link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /&gt;<br />
</code><br />
<code><br />
&lt;script type="text/javascript"&gt;<br />
function jsonFlickrFeed(json) {<br />
// Assign to a global variable<br />
window.jsonFromFlickr = json;<br />
}<br />
</code><br />
<code><br />
&lt;/script&gt;<br />
&lt;script type="text/javascript" src="http://api.flickr.com/services/feeds/photos_public.gne?id=YOUR-FLICKR-ID&amp;lang=en-us&amp;format=json"&gt;<br />
&lt;/script&gt;<br />
&lt;script type="text/javascript"&gt;<br />
function makePhoto(photo) {<br />
var li = document.createElement('li');<br />
var a = document.createElement('a');<br />
//a.href = photo.link;<br />
a.href = photo.media.m.replace('_m', '');<br />
a.rel = 'lightbox[Zorin]';<br />
a.title = photo.title;<br />
var img = document.createElement('img');<br />
img.src = photo.media.m.replace('_m', '_s');<br />
img.title = photo.title;<br />
img.alt = photo.alt;<br />
a.appendChild(img);<br />
li.appendChild(a);<br />
return li;<br />
}<br />
</code><br />
<code><br />
function showPhotos() {<br />
if (!jsonFromFlickr) {<br />
alert('Flickr photos failed to load');<br />
}<br />
// 'Empty' the ul by removing all of its children<br />
var ul = document.getElementById('photos');<br />
while (ul.hasChildNodes()) {<br />
ul.removeChild(ul.firstChild);<br />
}<br />
// Loop over the photos and display them all<br />
for (var i = 0; i &lt;= 9; i++) {<br />
photo = jsonFromFlickr.items[i];<br />
ul.appendChild(makePhoto(photo));<br />
}<br />
}<br />
</code><br />
<code><br />
window.onload = showPhotos;<br />
&lt;/script&gt;<br />
&lt;!--the following three scripts are required for Lightbox--&gt;<br />
&lt;script type="text/javascript" src="js/prototype.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="js/scriptaculous.js?load=effects"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript" src="js/lightbox.js"&gt;&lt;/script&gt;<br />
&lt;/head&gt;<br />
</code><br />
Lastly, pop the following into the body of the page:<br />
<code><br />
&lt;ul id="myPhotos"&gt;<br />
&lt;li&gt;&lt;a href="http://www.flickr.com/photos/myFlickrID/"&gt;ZorinWeb's Flickr Gallery&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
</code></p>
<p>If the global variable isn&#8217;t generated, you&#8217;ll be left with a link to your Flickr page, so it degrades gracefully&#8230;&#8230;.kind of. For a <strong>demo</strong>, please see <a href="http://misiek-mma.co.uk/gallery.html" target="_blank">Misiek&#8217;s site</a>.</p>
<p>This tutorial&#8217;s largely based on the abovementioned Sitepoint chapter, with the exception of the Lightbox effect added in by myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://zorinweb.com/2009/12/using-the-flickr-api-to-import-images-to-your-website/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

