<?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>Moa Nandorf</title>
	<atom:link href="http://moanandorf.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://moanandorf.com</link>
	<description>Learning Drupal is gorram hard. So I&#039;m going to write about it here. (And probably about other things, too.)</description>
	<lastBuildDate>Sun, 20 May 2012 15:42:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>WordPress: Split loop by value in custom field</title>
		<link>http://moanandorf.com/2012/wordpress-split-loop-by-value-in-custom-field/</link>
		<comments>http://moanandorf.com/2012/wordpress-split-loop-by-value-in-custom-field/#comments</comments>
		<pubDate>Sat, 19 May 2012 15:55:28 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=182</guid>
		<description><![CDATA[I recently had a site where I needed to split the result of a WP_Query into two loops, depending on the value in a custom field. Use case The use case was a list of gigs where I wanted to &#8230; <a href="http://moanandorf.com/2012/wordpress-split-loop-by-value-in-custom-field/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently had a site where I needed to split the result of a <code>WP_Query</code> into two loops, depending on the value in a custom field.<span id="more-182"></span></p>
<h3>Use case</h3>
<p>The use case was a list of gigs where I wanted to separate the upcoming gigs from the past gigs. For editor ease-of-use, I didn&#8217;t want to use the post date as the gig date, but instead chose to put the gig date in a custom field (with a little help from plugin <a href="http://wordpress.org/extend/plugins/advanced-custom-fields/">Advanced Custom Fields</a>).</p>
<p>Since it turned out to be the easiest way to accomplish what I wanted, I had the custom field save the date in the YYYY-MM-DD format. By doing that, I could reliably sort the dates &#8220;alphabetically&#8221; and not have the order break, since <code>meta_compare</code> treats all values as strings.</p>
<h3>Enter meta_compare</h3>
<p>meta_compare compares the value of a custom field to whatever other value you want to compare it with. In my case, I compared it to the date of the current day. Since I wanted two separate loops, this is what I did:<br />
<code><br />
$args = array(<br />
'post_type' =&gt; 'gigs',<br />
'meta_key'  =&gt; 'field_gigs_date',<br />
'orderby'   =&gt; 'meta_value',<br />
'order'     =&gt; 'ASC',<br />
'meta_compare' =&gt; '&gt;=',<br />
'meta_value' =&gt; $today,<br />
);<br />
$gigs = new WP_Query($args);</code></p>
<p><code>post_type</code> should be self-explanatory. <code>meta_key</code> is the name of the custom field which holds the first value you want to compare. My field name was <code>field_gigs_date</code>.<code>meta_value</code> is the other value you want to compare, in this case a variable that holds the current date in the same format as the date in my <code>field_gigs_date</code> field.</p>
<p><code>meta_compare</code> holds the operator. I wanted to display only gigs that had was happening right now or had not yet taken place, and therefore I used the greater than or equal to operator. The result is that the <code>$gigs</code> array contains dates that are bigger than or equal to today&#8217;s date, i.e. gigs that are happening as we speak or will happen in the future.</p>
<p><code>$args['meta_compare'] = '&lt;';<br />
$past_gigs = new WP_Query($args);</code></p>
<p>Since the only difference between the first and the second loop was the dates, the only thing I changed in my <code>$args</code> array was the <code>meta_compare</code> operator. The <code>$past_gigs</code> array will only contain gigs that have already taken place.</p>
<h3>Final result</h3>
<p>These two arrays were looped through in the normal WordPress fashion, by using <a href="http://codex.wordpress.org/The_Loop">The Loop</a>, but modified to use the new WP_Query object instead of the default one. Instead of the normal <code>have_posts()</code> call, make it use the newly created query object, <code>$gigs</code>. The same goes for the other method calls, so the final loop should end up looking like this:</p>
<p><code>if ($gigs-&gt;have_posts()) : while ($gigs-&gt;have_posts()) : $gigs-&gt;the_post();</code></p>
<p>Exchange <code>$gigs</code> for <code>$past_gigs</code> to loop through the past gigs object. Done!</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2012/wordpress-split-loop-by-value-in-custom-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redesign of moanandorf.com</title>
		<link>http://moanandorf.com/2012/redesign-of-moanandorf-com/</link>
		<comments>http://moanandorf.com/2012/redesign-of-moanandorf-com/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 09:35:33 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=171</guid>
		<description><![CDATA[I was growing increasingly frustrated with my old layout, so I put this new one together. It&#8217;s very much a work in progress, but I decided to put it up anyway. What better way to motivate me to work on &#8230; <a href="http://moanandorf.com/2012/redesign-of-moanandorf-com/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was growing increasingly frustrated with my old layout, so I put this new one together. It&#8217;s very much a work in progress, but I decided to put it up anyway. What better way to motivate me to work on it than looking at my broken-looking site every day?</p>
<p>I did have a moment of doubt as whether I should stick with WordPress or switch to Drupal, but I came to the conclusion that I still agree with <a title="Drupal vs. WordPress" href="http://moanandorf.com/2011/drupal-vs-wordpress/">what I wrote earlier</a>, and that I want to keep up with what&#8217;s going on with WordPress as well. No better way than keeping my blog running on WP.</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2012/redesign-of-moanandorf-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing page titles in Panels</title>
		<link>http://moanandorf.com/2012/removing-page-titles-in-panels/</link>
		<comments>http://moanandorf.com/2012/removing-page-titles-in-panels/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 11:45:50 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=157</guid>
		<description><![CDATA[Something that&#8217;s been driving me crazy with the otherwise excellent Panels module &#8211; there is no GUI way of removing the double page titles that show up sometimes! I solved it in the following way, which may or may not &#8230; <a href="http://moanandorf.com/2012/removing-page-titles-in-panels/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Something that&#8217;s been driving me crazy with the otherwise excellent Panels module &#8211; there is no GUI way of removing the double page titles that show up sometimes! I solved it in the following way, which may or may not be a good way, but it works so I&#8217;m using it until someone convinces me it&#8217;s a lousy idea.</p>
<pre class="brush: php; title: ; notranslate">function THEMENAME_preprocess_panels_pane(&amp;$vars) {
// remove page titles from the page, but leave them in &lt;title&gt;
 if ($vars['pane']-&gt;type == &quot;MACHINE_NAME_OF_PANE&quot; ) {
 unset($vars['title']);
}
}</pre>
<p>This code in the theme&#8217;s template.php, and in the panels-pane.tpl.php file, a few isset()s to check if the title is set before printing it, so as to avoid PHP notices. Come to think of it, if you set <code>$vars['title']</code> to <code>FALSE</code> instead of unsetting it, it should probably work without changing the tpl file. Haven&#8217;t tested it, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2012/removing-page-titles-in-panels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile first &#8211; for real</title>
		<link>http://moanandorf.com/2012/mobile-first-for-real/</link>
		<comments>http://moanandorf.com/2012/mobile-first-for-real/#comments</comments>
		<pubDate>Sat, 24 Mar 2012 11:21:29 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=138</guid>
		<description><![CDATA[During the last couple of weeks I&#8217;ve taken it upon myself to redesign a site I did for a friend in June 2009. I&#8217;ve been annoyed with a few aspects of the site for a while now, and when a &#8230; <a href="http://moanandorf.com/2012/mobile-first-for-real/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>During the last couple of weeks I&#8217;ve taken it upon myself to redesign a site I did for a friend in June 2009. I&#8217;ve been annoyed with a few aspects of the site for a while now, and when a <a href="http://drupal.org">WordPress</a> security update broke the image uploader the site&#8217;s using, I decided to move it to <a href="http://drupal.org">Drupal</a> and do a redesign while I&#8217;m at it.</p>
<p>The look and feel of the site will mostly stay the same, but I&#8217;m almost completely changing the structure of the site. The front page is getting a more clear &#8220;call to action&#8221; and the administrative workflow will be more intuitive. And, the site will, of course, be fully responsive. It&#8217;s the third responsive site I&#8217;m building that will actually go live, but what&#8217;s different about this one is that it&#8217;s built with a mobile first approach.<span id="more-138"></span></p>
<h3>Prioritize! And wireframes.</h3>
<p>Since I had already decided to do a restructuring with only minor changes to the graphical elements, I started where I should really <em>always</em> start &#8211; with wireframes. I use <a title="website wireframes" href="https://gomockingbird.com/">Mockingbird</a> and did wireframes for four &#8220;states&#8221;: mobile, tablet, screen and huge-ass screen, starting with mobile.</p>
<p>Doing that really forced me to prioritize! What elements are most important? What elements do I think the visitor will find less important? If they are less important, maybe they are in fact <em>un</em>important and should be done away with altogether?</p>
<p>Thinking these question through left me with a very prioritized one-column layout, and extending that into two- and three-column layouts became surprisingly easy. It was &#8220;only&#8221; a matter of figuring out what options I had for reflowing content within the HTML structure that was set with the one-column layout.</p>
<h3>Grid-less</h3>
<p>While doing the wireframes I was using a grid for helping with proportions between elements, but once I started coding, I felt the grid classes were more of a hindrance than a help.</p>
<p>I haven&#8217;t quite figured out how a responsive grid is supposed to work at breakpoints where a layout changes its number of columns. Does the previously four-grid sidebar go full-width despite still having a .grid_4 class? What about a site that goes from one column on mobile to four column on large screens? It seems to me like the grid classes will have different meanings depending on the layout, and that is way confusing to me. But I&#8217;m not sure I&#8217;ve understood it all correctly.</p>
<p>So I took all the grid classes out.</p>
<p>Looking at my wireframes, I created a <a href="http://drupal.org/project/panels_everywhere">Panels Everywhere</a> site template layout with five areas: header, primary content, secondary content, tertiary content, and footer. When I felt the the line-length of the one-column layout was getting too long to comfortably read, I moved the secondary content up and made it into a sidebar, and when I felt that the screen size was sufficiently large for accommodating yet another sidebar, I made the tertiary content move up into a second sidebar.</p>
<h3>It sounds so easy&#8230;</h3>
<p>&#8230; and it really was! Since I had done responsive before but not used the mobile first approach, I was prepared for more headaches trying to figure out where all the elements should go, and how they should get there. With all the elements prioritized and the HTML structure pretty much set from the beginning, I now feel that I have more time to fine-tune the typography and the graphical elements, and make it all look as good as possible regardless of screen size. Lessons learned:</p>
<ol>
<li>Always go <strong>mobile first</strong>, because it will make you&#8230;</li>
<li><strong>Prioritize</strong>! Between elements &#8211; most important first</li>
<li>It&#8217;s <strong>easier to scale up</strong> and add elements, than to scale down and remove elements.</li>
</ol>
<p>It&#8217;s particularly hard to remove elements (if that&#8217;s even what you should be doing &#8211; it depends on the site) if you do not have a clear idea of what&#8217;s most important.</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2012/mobile-first-for-real/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Even more typography</title>
		<link>http://moanandorf.com/2012/even-more-typography/</link>
		<comments>http://moanandorf.com/2012/even-more-typography/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 20:39:54 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=115</guid>
		<description><![CDATA[Lost Type]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.losttype.com/">Lost Type</a></p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2012/even-more-typography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More typography</title>
		<link>http://moanandorf.com/2011/more-typography/</link>
		<comments>http://moanandorf.com/2011/more-typography/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 22:30:49 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=113</guid>
		<description><![CDATA[Thinking with Type.]]></description>
			<content:encoded><![CDATA[<p><a title="Ellen Lupton" href="http://www.thinkingwithtype.com/">Thinking with Type</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2011/more-typography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Typography</title>
		<link>http://moanandorf.com/2011/typography/</link>
		<comments>http://moanandorf.com/2011/typography/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 11:11:16 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=108</guid>
		<description><![CDATA[Fonts in Use and Typography for Lawyers]]></description>
			<content:encoded><![CDATA[<p><a href="http://fontsinuse.com">Fonts in Use</a> and <a href="http://www.typographyforlawyers.com/">Typography for Lawyers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2011/typography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Succeed in Open Source (or Things I Learned from Writing My First Rules Condition)</title>
		<link>http://moanandorf.com/2011/how-to-succeed-in-open-source-or-things-i-learned-from-writing-my-first-rules-condition/</link>
		<comments>http://moanandorf.com/2011/how-to-succeed-in-open-source-or-things-i-learned-from-writing-my-first-rules-condition/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 19:56:46 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=102</guid>
		<description><![CDATA[My colleague Mattias keeps giving me one piece of great advice that I just keep forgetting. When you want to accomplish something, look at a piece of code that already does sort of what you want to do, copy and &#8230; <a href="http://moanandorf.com/2011/how-to-succeed-in-open-source-or-things-i-learned-from-writing-my-first-rules-condition/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My colleague <a title="Web developer at NodeOne" href="http://nodeone.se/en/people/mattias-hallkvist">Mattias</a> keeps giving me one piece of great advice that I just keep forgetting.</p>
<p>When you want to accomplish something, look at a piece of code that already does sort of what you want to do, copy and paste it, and modify it to work like you want it to.<span id="more-102"></span></p>
<p>Today I wrote my first <a href="https://drupal.org/project/rules">Rules</a> condition and I struggled for a <em>quite some time</em> with accessing the parameter I wanted from my condition function. I wanted a node object, and despite digging through the documentation I couldn&#8217;t seem to get it right. (Or, as it turned out, I actually got it right but must&#8217;ve mistyped something, but that&#8217;s beside the point.) Giving up, I turned to Mattias and as soon as he&#8217;d understood my plight he told me to look at an exisiting condition that did just that &#8211; accessed a node object.</p>
<p>For example, the very standard &#8220;Content is of type&#8221; condition.</p>
<p>Problem solved in less than two minutes. I am writing it down in the hopes of actually remembering this all by myself next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2011/how-to-succeed-in-open-source-or-things-i-learned-from-writing-my-first-rules-condition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Befunnit mig på gymmet</title>
		<link>http://moanandorf.com/2011/befunnit-mig-pa-gymmet/</link>
		<comments>http://moanandorf.com/2011/befunnit-mig-pa-gymmet/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 16:19:27 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Träning]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=91</guid>
		<description><![CDATA[I går promenerade jag till gymmet och sprang på löpbandet i 20 minuter. Hann tyvärr inte mer då jag var så seg med att komma iväg att de höll på att stänga. Nu ska jag &#8220;bara&#8221; se till att detta &#8230; <a href="http://moanandorf.com/2011/befunnit-mig-pa-gymmet/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I går promenerade jag till gymmet och sprang på löpbandet i 20 minuter. Hann tyvärr inte mer då jag var så seg med att komma iväg att de höll på att stänga.</p>
<p>Nu ska jag &#8220;bara&#8221; se till att detta blir starten på regelbunden träning! Två gånger i veckan fram till jul, det borde väl inte vara omöjligt?</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2011/befunnit-mig-pa-gymmet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filefield Zip &#8211; a Drupal module for zipping filefield files.</title>
		<link>http://moanandorf.com/2011/filefield-zip-a-drupal-module-for-zipping-filefield-files/</link>
		<comments>http://moanandorf.com/2011/filefield-zip-a-drupal-module-for-zipping-filefield-files/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 19:40:17 +0000</pubDate>
		<dc:creator>Moa Nandorf</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://moanandorf.com/?p=88</guid>
		<description><![CDATA[Micke and I are building a module! I have built modules before, but mostly custom modules for specific sites and only one that was ever intended to be released (but it never was). We&#8217;re calling it Filefield Zip, and it &#8230; <a href="http://moanandorf.com/2011/filefield-zip-a-drupal-module-for-zipping-filefield-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://nodeone.se/user/9">Micke</a> and I are building a module! I have built modules before, but mostly custom modules for specific sites and only one that was ever intended to be released (but it never was).</p>
<p>We&#8217;re calling it <a href="http://drupal.org/sandbox/MickeA/1345624">Filefield Zip</a>, and it takes files from one or more selected file fields and zips them into one single zip-file. Right now, that&#8217;s all it does, but we&#8217;re planning to add Views support for a link to download the zip file and a whole bunch of other features. This module started as a project for a NodeOne client whose site is on Drupal 6, so for now the module is for D6 with plans to port it to Drupal 7 when we have time.</p>
]]></content:encoded>
			<wfw:commentRss>http://moanandorf.com/2011/filefield-zip-a-drupal-module-for-zipping-filefield-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: moanandorf.com @ 2012-05-21 02:25:27 -->
