<?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>Kristian Lunde &#187; Drupal</title>
	<atom:link href="http://www.klunde.net/category/applications/drupal/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klunde.net</link>
	<description>www.klunde.net</description>
	<lastBuildDate>Sun, 18 Jul 2010 21:00:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting the default option of a ubercart product attribute</title>
		<link>http://www.klunde.net/2009/02/20/getting-the-default-option-of-a-ubercart-product-attribute/</link>
		<comments>http://www.klunde.net/2009/02/20/getting-the-default-option-of-a-ubercart-product-attribute/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 22:02:57 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[Ubercart]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=262</guid>
		<description><![CDATA[
			
				
			
		
In Orange Bus we are currently busy building a new web shop for a clothing company. We are building this web shop on Drupal 6 and Ubercart 2. While I was doing some tuning of the product page (built as a node template) on this site I suddenly realized that even though you can get [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F02%2F20%2Fgetting-the-default-option-of-a-ubercart-product-attribute%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2009_2F02_2F20_2Fgetting-the-default-option-of-a-ubercart-product-attribute_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2009%2F02%2F20%2Fgetting-the-default-option-of-a-ubercart-product-attribute%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In Orange Bus we are currently busy building a new web shop for a clothing company. We are building this web shop on Drupal 6 and Ubercart 2. While I was doing some tuning of the product page (built as a node template) on this site I suddenly realized that even though you can get most of the information needed in from the <i>$node</i> object, you are unable to get the default options of each attribute.</p>
<p>In my case this attribute was the sizes of the products (small, medium, large and so on), the node object contained all the attributes but not the default options. It is not at all complicated to get this information but you do need to add some custom code to get a hold of the default options. I would argue that this should be included in the default node object, which really should not be a big deal adding. I guess I should add a patch for this, instead of going around the problem which is what I do and describe here. </p>
<p>To get a hold of this I had to call a ubercart specific function called <i>uc_product_get_attributes</i> function. This function takes a node id as parameter and return all an array of all the attributes related to the node. The array contain a set of attributes objects and these object contain all the information available on each attribute.</p>
<p>My solution was to call the <i>uc_product_get_attributes</i> function and get the <i>default_option</i> variable from the attribute object, see code example below.</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="co1">//get all attributes related to the node</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$attributes</span> <span class="sy0">=</span> uc_product_get_attributes<span class="br0">&#40;</span><span class="re1">$node</span><span class="sy0">-&gt;</span><span class="me1">nid</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//get the id of default size of the product</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$default_size</span> <span class="sy0">=</span> <span class="re1">$attributes</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">-&gt;</span><span class="me1">default_option</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>It is simple, but it took me about an 30 minutes to determine the problem and adding a solution. Hopefully this will save someone the job of solving the same problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2009/02/20/getting-the-default-option-of-a-ubercart-product-attribute/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding and editing pages in your drupal module</title>
		<link>http://www.klunde.net/2008/12/02/adding-and-editing-pages-in-your-drupal-module/</link>
		<comments>http://www.klunde.net/2008/12/02/adding-and-editing-pages-in-your-drupal-module/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 21:42:44 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=195</guid>
		<description><![CDATA[
			
				
			
		
Whenever you are adding  or editing pages to your module, remember to refresh the admin -&#62; site building -&#62; modules or your changes will not take effect.
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F12%2F02%2Fadding-and-editing-pages-in-your-drupal-module%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F12_2F02_2Fadding-and-editing-pages-in-your-drupal-module_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F12%2F02%2Fadding-and-editing-pages-in-your-drupal-module%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Whenever you are adding  or editing pages to your module, remember to refresh the <em>admin -&gt; site building -&gt; modules</em> or your changes will not take effect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/12/02/adding-and-editing-pages-in-your-drupal-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding standard, coding style</title>
		<link>http://www.klunde.net/2008/11/11/coding-standard-coding-style/</link>
		<comments>http://www.klunde.net/2008/11/11/coding-standard-coding-style/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 22:53:25 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[coding style]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=185</guid>
		<description><![CDATA[
			
				
			
		
In Orange Bus we have been looking at our coding style lately. We have created our very own coding standard. Since we base most of our applications on the drupal we chose to use the drupal coding standard as our main source of inspiration.
During our process of creating this coding standard we found a few [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F11%2F11%2Fcoding-standard-coding-style%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F11_2F11_2Fcoding-standard-coding-style_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F11%2F11%2Fcoding-standard-coding-style%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>In <a href="http://www.orangebus.co.uk" onclick="urchinTracker('/outgoing/www.orangebus.co.uk?referer=');">Orange Bus</a> we have been looking at our coding style lately. We have created our very own coding standard. Since we base most of our applications on the drupal we chose to use the <a href="http://www.drupal.org" onclick="urchinTracker('/outgoing/www.drupal.org?referer=');">drupal</a> coding standard as our main source of inspiration.<br />
During our process of creating this coding standard we found a few good links I thought we should share. </p>
<p><a href="http://yeknaa.wordpress.com/" onclick="urchinTracker('/outgoing/yeknaa.wordpress.com/?referer=');">Mike</a> @ <a href="http://www.orangebus.co.uk" onclick="urchinTracker('/outgoing/www.orangebus.co.uk?referer=');">Orange Bus</a> found these two articles about beautiful and practical code, both these are a must read:</p>
<p><a href="http://www.wilshipley.com/blog/2007/05/pimp-my-code-part-14-be-inflexible.html" onclick="urchinTracker('/outgoing/www.wilshipley.com/blog/2007/05/pimp-my-code-part-14-be-inflexible.html?referer=');">http://www.wilshipley.com/blog/2007/05/pimp-my-code-part-14-be-inflexible.html</a></p>
<p><a href="http://www.perforce.com/perforce/papers/prettycode.html" onclick="urchinTracker('/outgoing/www.perforce.com/perforce/papers/prettycode.html?referer=');">http://www.perforce.com/perforce/papers/prettycode.html</a></p>
<p>Another blog post  about line density worth reading is:</p>
<p><a href="http://paul-m-jones.com/?p=276" onclick="urchinTracker('/outgoing/paul-m-jones.com/?p=276&amp;referer=');">http://paul-m-jones.com/?p=276</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/11/11/coding-standard-coding-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All frameworks sucks&#8230;. ?</title>
		<link>http://www.klunde.net/2008/10/25/all-frameworks-sucks/</link>
		<comments>http://www.klunde.net/2008/10/25/all-frameworks-sucks/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 22:40:01 +0000</pubDate>
		<dc:creator>Kristian Lunde</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.klunde.net/?p=126</guid>
		<description><![CDATA[
			
				
			
		
I&#8217;ve been hearing this a lot lately, that most framework sucks, well do they? 
Mr. Paul M. Jones has a really good article about the subject, he says that when a developer has to do a major change in his mindset and development routines to get used to a new framework, the developer often think [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F10%2F25%2Fall-frameworks-sucks%2F" onclick="urchinTracker('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.klunde.net_2F2008_2F10_2F25_2Fall-frameworks-sucks_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.klunde.net%2F2008%2F10%2F25%2Fall-frameworks-sucks%2F&amp;source=kristianlunde&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve been hearing this a lot lately, that most framework sucks, well do they? </p>
<p>Mr. <a href="http://paul-m-jones.com/?p=355" onclick="urchinTracker('/outgoing/paul-m-jones.com/?p=355&amp;referer=');">Paul M. Jones</a> has a really good article about the subject, he says that when a developer has to do a major change in his mindset and development routines to get used to a new framework, the developer often think that the &#8220;framework sucks&#8221;.</p>
<p>Personally I&#8217;ve been the kind of developer who like to write my own frameworks from scratch, and yes that also mean that I&#8217;ve written a couple of frameworks for myself, and threw them away. Since I like to write things from the scratch I&#8217;ve also been a bit critical to other frameworks,and I do understand  term &#8220;all frameworks sucks&#8221;. When you&#8217;ve written your own framework, you know how it works, and it works just the way you want it to, at least that was the goal of writing it in the first place. It also gives you the possibility to change or add functionality in the core of the framework rather easily.</p>
<p>The advantages with a &#8220;off the shelf&#8221; framework can sometimes be intriguing, with a little bit of effort you can become darn efficent with this kind of framework, that will of course require a bit from the developer to learn the framework. Another bonus about learning a new framework is that you pick up on some of the bright ideas the developers have implemented in their framework.</p>
<p>I do not think that all frameworks sucks but, there are some frameworks out there that do not match my mindset at all, there is no secret that I&#8217;m not a huge fan of large enterprise frameworks with a wide extent of xml files and structures (I&#8217;m not naming any names, but the Java world have a few of these). Why on earth would you need to define a new page in three different xml files to get it working? </p>
<p>I&#8217;ve heard a lot about <a href="http://codeigniter.com/" onclick="urchinTracker('/outgoing/codeigniter.com/?referer=');">Code Ignitor</a> and it sounds like a promising framework, I have not had the time to have a look at it yet. I am familiar with the <a href="http://framework.zend.com/" onclick="urchinTracker('/outgoing/framework.zend.com/?referer=');">Zend framework</a> and <a href="http://ez.no/ezcomponents" onclick="urchinTracker('/outgoing/ez.no/ezcomponents?referer=');">EZ components</a> which probably are more of a set of building bricks than frameworks, both of these are quite good and comfortable to work with. </p>
<p>Recently I&#8217;ve started to look at the <a href="http://drupal.org" onclick="urchinTracker('/outgoing/drupal.org?referer=');">Drupal</a>. I realize that Drupal is more of a content management system than a framework, but it has its similarities to a framework. So far I still think Drupal &#8220;sucks&#8221; <img src='http://www.klunde.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  but I do however like  the simplicity of writing modules. What I do not like at all is the &#8220;lack&#8221; of OOP, and yes I know Drupal have its own way of implementing OOP, but I still feels thats is a little bit awkward, I am a bit of a OOP junkie <img src='http://www.klunde.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /><br />
Anyway I see the potential of Drupal and look forward to getting to know it better. I believe I eventually will  like Drupal because it is easy to extend, you get a lot of stuff for free because someone has already written it for you and it is a big community around it with a lot of smart developers. There is probably a reason why Drupal is one of the largest PHP framework out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klunde.net/2008/10/25/all-frameworks-sucks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
