<?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>citytree</title>
	<atom:link href="http://www.citytree.be/feed" rel="self" type="application/rss+xml" />
	<link>http://www.citytree.be</link>
	<description>The open source CMS specialist</description>
	<lastBuildDate>Wed, 09 Nov 2011 13:17:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Easily select nodes with EntityFieldQuery</title>
		<link>http://www.citytree.be/blog/easily-select-nodes-with-entityfieldquery</link>
		<comments>http://www.citytree.be/blog/easily-select-nodes-with-entityfieldquery#comments</comments>
		<pubDate>Wed, 05 Oct 2011 14:45:23 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal7]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=518</guid>
		<description><![CDATA[Remember the old times in Drupal 6 when you needed to do complicated join to select nodes. Now it&#8217;s (quite&#8230;) easy with EntityFieldQuery. But this is not much documented so I will provide some examples. 1. select the 50 latest news (that are node referenced) then you can retrieve formatted result by using 2. select [...]]]></description>
			<content:encoded><![CDATA[<p>Remember the old times in Drupal 6 when you needed to do complicated join to select nodes.</p>
<p>Now it&#8217;s (quite&#8230;) easy with EntityFieldQuery. But this is not much documented so I will provide some examples.</p>
<p>1. select the 50 latest news (that are node referenced)</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="re0">$query</span> = <span class="kw2">new</span> EntityFieldQuery<span class="br0">&#40;</span><span class="br0">&#41;</span>;
<span class="re0">$result</span> = <span class="re0">$query</span>-<span class="sy0">&gt;</span><span class="me1">entityCondition</span><span class="br0">&#40;</span><span class="st0">'entity_type'</span>, <span class="st0">'node'</span>, <span class="st0">'='</span><span class="br0">&#41;</span> <span class="co1">// select nodes</span>
		          -<span class="sy0">&gt;</span><span class="me1">propertyCondition</span><span class="br0">&#40;</span><span class="st0">'type'</span>, <span class="st0">'news'</span>, <span class="st0">'='</span><span class="br0">&#41;</span> <span class="co1">//type news</span>
		          -<span class="sy0">&gt;</span><span class="me1">propertyCondition</span><span class="br0">&#40;</span><span class="st0">'status'</span>, <span class="st0">'1'</span><span class="br0">&#41;</span> <span class="co1">//published, you don't need to add '=' it's added by default</span>
		          -<span class="sy0">&gt;</span><span class="me1">fieldCondition</span><span class="br0">&#40;</span><span class="st0">'field_newapp'</span>, <span class="st0">'nid'</span>, <span class="nu0">0</span>, <span class="st0">'&gt;'</span><span class="br0">&#41;</span> <span class="co1">// node referenced so the 2nd parameter is nid</span>
		          -<span class="sy0">&gt;</span><span class="me1">propertyOrderBy</span><span class="br0">&#40;</span><span class="st0">'created'</span>, <span class="st0">'desc'</span><span class="br0">&#41;</span> <span class="co1">//most recent first</span>
		          -<span class="sy0">&gt;</span><span class="me1">range</span><span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">50</span><span class="br0">&#41;</span> <span class="co1">// limit</span>
		          -<span class="sy0">&gt;</span><span class="me1">execute</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</pre></div></div>
<p>then you can retrieve formatted result by using</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="re0">$news</span> = node_view_multiple<span class="br0">&#40;</span>node_load_multiple<span class="br0">&#40;</span><a href="http://www.php.net/array_keys"><span class="kw3">array_keys</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#91;</span><span class="st0">'node'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>, <span class="st0">'full'</span><span class="br0">&#41;</span>;</pre></div></div>
<p><br class="spacer_" /></p>
<p>2. select all documents with title beginning with Management report belonging to &#8216;int&#8217; and &#8216;both&#8217;</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="re0">$query</span> = <span class="kw2">new</span> EntityFieldQuery<span class="br0">&#40;</span><span class="br0">&#41;</span>;
<span class="re0">$query</span>-<span class="sy0">&gt;</span><span class="me1">entityCondition</span><span class="br0">&#40;</span><span class="st0">'entity_type'</span>, <span class="st0">'node'</span><span class="br0">&#41;</span> <span class="co1">// the third '=' is not necessary</span>
 -<span class="sy0">&gt;</span><span class="me1">propertyCondition</span><span class="br0">&#40;</span><span class="st0">'type'</span>, <span class="st0">'document'</span><span class="br0">&#41;</span>
 -<span class="sy0">&gt;</span><span class="me1">propertyCondition</span><span class="br0">&#40;</span><span class="st0">'title'</span>, <span class="st0">'Management report%'</span>, <span class="st0">'like'</span><span class="br0">&#41;</span> <span class="co1">// here we use the 'like' operator</span>
-<span class="sy0">&gt;</span><span class="me1">fieldCondition</span><span class="br0">&#40;</span><span class="st0">'field_appintext'</span>, <span class="st0">'value'</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">'int'</span>,<span class="st0">'both'</span><span class="br0">&#41;</span>, <span class="st0">'IN'</span><span class="br0">&#41;</span> <span class="co1">// 'in' operator</span>
 -<span class="sy0">&gt;</span><span class="me1">execute</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</pre></div></div>
<p><br class="spacer_" /></p>
<p>3. check if 2 conditions are met (AND)</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="re0">$query</span> = <span class="kw2">new</span> EntityFieldQuery<span class="br0">&#40;</span><span class="br0">&#41;</span>;
<span class="re0">$query</span>-<span class="sy0">&gt;</span><span class="me1">entityCondition</span><span class="br0">&#40;</span><span class="st0">'entity_type'</span>, <span class="st0">'node'</span><span class="br0">&#41;</span>
 -<span class="sy0">&gt;</span><span class="me1">propertyCondition</span><span class="br0">&#40;</span><span class="st0">'type'</span>, <span class="st0">'status'</span><span class="br0">&#41;</span>
 -<span class="sy0">&gt;</span><span class="me1">fieldCondition</span><span class="br0">&#40;</span><span class="st0">'field_selectlistreq'</span>, <span class="st0">'value'</span>, <span class="re0">$env</span><span class="br0">&#91;</span><span class="re0">$current</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">'type'</span><span class="br0">&#93;</span>, <span class="st0">'!='</span><span class="br0">&#41;</span> <span class="co1">//note the 2nd parameter 'value'</span>
 -<span class="sy0">&gt;</span><span class="me1">fieldCondition</span><span class="br0">&#40;</span><span class="st0">'field_appxmlid'</span>, <span class="st0">'value'</span>, <span class="re0">$id</span><span class="br0">&#41;</span>
-<span class="sy0">&gt;</span><span class="me1">fieldOrderBy</span><span class="br0">&#40;</span><span class="st0">'field_appname'</span>, <span class="st0">'value'</span><span class="br0">&#41;</span> <span class="co1">//sort on a field property</span>
-<span class="sy0">&gt;</span><span class="me1">execute</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</pre></div></div>
<p><br class="spacer_" /></p>
<p>4. 2 conditions with OR</p>
<p>or seems not to be supported <img src='http://www.citytree.be/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>5. select users</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="re0">$query</span> = <span class="kw2">new</span> EntityFieldQuery<span class="br0">&#40;</span><span class="br0">&#41;</span>;
<span class="re0">$query</span>-<span class="sy0">&gt;</span><span class="me1">entityCondition</span><span class="br0">&#40;</span><span class="st0">'entity_type'</span>, <span class="st0">'user'</span><span class="br0">&#41;</span>
 -<span class="sy0">&gt;</span><span class="me1">fieldCondition</span><span class="br0">&#40;</span><span class="st0">'field_postcode'</span>, <span class="st0">'value'</span>, <span class="re0">$postcode</span><span class="br0">&#41;</span>;</pre></div></div>
<p>then select them with</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="re0">$napps</span> = user_view_multiple<span class="br0">&#40;</span>user_load_multiple<span class="br0">&#40;</span><a href="http://www.php.net/array_keys"><span class="kw3">array_keys</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#91;</span><span class="st0">'user'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>, <span class="st0">'full'</span><span class="br0">&#41;</span>;</pre></div></div>
<p><br class="spacer_" /></p>
<p>6. select terms (&#8216;projects&#8217; vocabulary for current user)</p>
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="re0">$result</span> = <span class="re0">$query</span>-<span class="sy0">&gt;</span><span class="me1">entityCondition</span><span class="br0">&#40;</span><span class="st0">'entity_type'</span>, <span class="st0">'taxonomy_term'</span><span class="br0">&#41;</span>
 -<span class="sy0">&gt;</span><span class="me1">entityCondition</span><span class="br0">&#40;</span><span class="st0">'bundle'</span>, <span class="st0">'projects'</span><span class="br0">&#41;</span>
 -<span class="sy0">&gt;</span><span class="me1">fieldCondition</span><span class="br0">&#40;</span><span class="st0">'field_relatedusers'</span>, <span class="st0">'uid'</span>, <span class="re0">$GLOBALS</span><span class="br0">&#91;</span><span class="st0">'user'</span><span class="br0">&#93;</span>-<span class="sy0">&gt;</span><span class="me1">uid</span><span class="br0">&#41;</span>
 -<span class="sy0">&gt;</span><span class="me1">execute</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
<span class="co1">//select with</span>
 <span class="re0">$tids</span> = taxonomy_term_load_multiple<span class="br0">&#40;</span><a href="http://www.php.net/array_keys"><span class="kw3">array_keys</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#91;</span><span class="st0">'taxonomy_term'</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</pre></div></div>
<p>you can select files as well&#8230;</p>
<p>more technical info on <a href="http://api.drupal.org/api/drupal/includes--entity.inc/class/EntityFieldQuery/7">Drupal API</a>. some <a href="http://drupal.org/node/916776">examples</a> on the Drupal site</p>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/easily-select-nodes-with-entityfieldquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide input format and filter tips</title>
		<link>http://www.citytree.be/blog/hide-input-format-and-filter-tips</link>
		<comments>http://www.citytree.be/blog/hide-input-format-and-filter-tips#comments</comments>
		<pubDate>Tue, 19 Apr 2011 11:05:13 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal7]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=507</guid>
		<description><![CDATA[When you are using the default Seven as your admin theme, it&#8217;s not convenient to hide the input format and filter tips because your custom theme css is not loaded at this point. The trick is to load a css in a custom module and once your module will be enabled, the css will be [...]]]></description>
			<content:encoded><![CDATA[<p>When you are using the default Seven as your admin theme, it&#8217;s not convenient to hide the input format and filter tips because your custom theme css is not loaded at this point.</p>
<p>The trick is to load a css in a custom module and once your module will be enabled, the css will be integrated in the seven theme.<br />
 for instance:<br />
 <div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;"><span class="kw2">function</span> mymodule_init<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
 <a href="http://api.drupal.org/api/function/drupal_add_css"><span class="kw5">drupal_add_css</span></a><span class="br0">&#40;</span><a href="http://api.drupal.org/api/function/drupal_get_path"><span class="kw5">drupal_get_path</span></a><span class="br0">&#40;</span><span class="st0">'module'</span>, <span class="st0">'mymodule'</span><span class="br0">&#41;</span>.<span class="st0">&quot;/css/myseven.css&quot;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">'group'</span> =<span class="sy0">&gt;</span> CSS_DEFAULT, <span class="st0">'every_page'</span> =<span class="sy0">&gt;</span> <span class="kw2">TRUE</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
 <span class="br0">&#125;</span></pre></div></div><br />
 then you can easily overwrite the css of seven and hide the input format chooser and filter tips<br />
 <div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><pre class="css" style="font-family:monospace;"><span class="re1">.filter-wrapper</span> <span class="br0">&#123;</span><span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span><span class="br0">&#125;</span></pre></div></div></p>
<p><strong>edit</strong>: sometimes, it&#8217;s not enough to only apply custom  css formatting to your admin theme, you need custom template files. The trick is to create a simple temlate with seven as base theme.</p>
<p>Create a new folder &#8220;myseven&#8221; with file myseven.info inside<br />
 <div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><pre class="drupal" style="font-family:monospace;">core = <span class="st0">&quot;7.x&quot;</span>
 engine = phptemplate
name = My Seven
 description = seven customized
 base <a href="http://api.drupal.org/api/function/theme"><span class="kw5">theme</span></a> = seven</pre></div></div></p>
<p>and you have a new fully functionnal theme, identical to seven but ready to be customized.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/hide-input-format-and-filter-tips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Notice: Undefined index&#8221; quick fix in drupal7 error reporting</title>
		<link>http://www.citytree.be/blog/undefined-index-quick-fix-in-drupal7-error-reporting</link>
		<comments>http://www.citytree.be/blog/undefined-index-quick-fix-in-drupal7-error-reporting#comments</comments>
		<pubDate>Wed, 23 Mar 2011 15:39:05 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal7]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=483</guid>
		<description><![CDATA[In drupal 7 , the error reporting settings in php.ini is overridden by the bootstrap sequence. Even error reporting changes in your htaccess won&#8217;t work&#8230; drupal force you to use E_ALL , the new standard for upcoming php 6 As result some modules may produce undefined variables that will be displayed as messages &#8220;Notice: Undefined [...]]]></description>
			<content:encoded><![CDATA[<p>In drupal 7 , the error reporting settings in php.ini is overridden by the bootstrap sequence. Even error reporting changes in your htaccess won&#8217;t work&#8230; drupal force you to use E_ALL , the new standard for upcoming php 6</p>
<p>As result some modules may produce undefined variables that will be displayed as messages &#8220;Notice: Undefined index&#8221; or &#8220;Notice: Undefined variable&#8221; and your logs will grow insanely&#8230;</p>
<p>the solution is to add in your settings.php the line <div id="wpshdo_11" class="wp-synhighlighter-outer"><div id="wpshdt_11" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_11"></a><a id="wpshat_11" class="wp-synhighlighter-title" href="#codesyntax_11"  onClick="javascript:wpsh_toggleBlock(11)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_11" onClick="javascript:wpsh_code(11)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_print(11)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_11" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><a href="http://www.php.net/ini_set"><span class="kw3">ini_set</span></a><span class="br0">&#40;</span><span class="st_h">'error_reporting'</span><span class="sy0">,</span> <span class="st_h">'E_ALL ^ E_NOTICE'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div> to micmic the default behavior of php 5.2</p>
<p><br class="spacer_" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/undefined-index-quick-fix-in-drupal7-error-reporting/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Provide a clean back end interface for your client</title>
		<link>http://www.citytree.be/blog/provide-a-clean-back-end-interface-for-your-client</link>
		<comments>http://www.citytree.be/blog/provide-a-clean-back-end-interface-for-your-client#comments</comments>
		<pubDate>Thu, 07 Oct 2010 08:55:12 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=463</guid>
		<description><![CDATA[Out of the box, drupal doesn&#8217;t provide an easy to use interface to administer the website. Luckily with a few contrib modules you can greatly enhance that! If you client is not an informatic guru, he will love it : a nice design for the interface that displays only the used menu items. Unused functionalities [...]]]></description>
			<content:encoded><![CDATA[<p>Out of the box, drupal doesn&#8217;t provide an easy to use interface to administer the website. Luckily with a few contrib modules you can greatly enhance that! <br />
 If you client is not an informatic guru, he will love it : a nice design for the interface that displays only the used menu items. Unused functionalities like input format or statuses can be safely removed.</p>
<p>Less options means easier management and happier client!</p>
<h3>step 1 : install a dedicated administration theme</h3>
<p><a href="http://drupal.org/project/admin">admin module</a><br />
 you can install the <strong>6.x.1.0</strong> .The theme will be set immediately after installation but you will have less control on it (it&#8217;s not really a new theme) and the admin menu items will be changed, so be warned if you plan to use the admin_menu module!<br />
 the <strong>6.x.2.0</strong> requires you to install the <a href="http://code.developmentseed.org/rubik">rubik theme</a> and the <a href="http://drupal.org/project/tao">tao</a> . the rubik theme is a child of tao. You have to manually enable the 2 themes in admin/build/themes/select and choose rubik as admin theme in admin/settings/admin/theme.</p>
<p>You can also add the <a href="http://drupal.org/project/admin_theme">admin_theme module</a> if you want your admin theme to be displayed on other pages than admin/* and check the box &#8220;Content editing&#8221; in admin/settings/admin/theme.<br />
 If you need extra controls over the theme, you can create a new one that will be a child of rubik (add the line base theme = &#8220;rubik&#8221; in the .info file). You will customize it by adding a template.php and other tpl files (and leave the tao files unchanged  &#8211; always better&#8230;).</p>
<p>do not forget to set the permission &#8220;access admin theme&#8221; to your client&#8217;s role.</p>
<p><br class="spacer_" /></p>
<h3>step 2 : better formats</h3>
<p>this module helps you to control the input formats by settings defaults (and removing the format chooser in node, blocks and comments management)<br />
 install <a href="http://drupal.org/project/better_formats">the module</a> go to admin/settings/filters/defaults and choose the default input formats. Then on admin/user/permissions uncheck the boxes to remove format selection, tips and links (they are checked by default&#8230;)</p>
<h3>step 3 : Form filter</h3>
<p>If you have granted your user the &#8220;administer nodes&#8221; permission, the node/add and node/edit forms will show revision information, authoring information and publishing options (and other options provided by additional modules). These options are not always useful so if you want to remove it you can do it by code (hook_form_alter &#8211; btw I didn&#8217;t find an easier way than hide by css with $form['my_element'][#prefix] = &#8216;&lt;div style=&#8221;display:none&#8221;&gt;&#8217; and $form['my_element'][#suffix] = &#8216;&lt;/div&gt;&#8217;). <br />
 But you can do it also with the <a href="http://drupal.org/project/formfilter">form filter module</a>. Enable both formfilter module and formfilter ui. As administrator, 2 links will appear on the bottom of the node/add and edit pages.<br />
 You can click on &#8220;Filter all node forms&#8221; and check the 3 boxes &#8220;<em>Hide Revision information</em>&#8220;, &#8220;<em>Hide Authoring information</em>&#8221; and &#8220;<em>Hide Publishing options</em>&#8220;.</p>
<p>you can also choose a role with &#8220;<em>view forms without filtering</em>&#8221; permission.</p>
<h3>step 4 : <a href="http://drupal.org/project/menu_per_role">Menu per role</a></h3>
<p>This is a quick and dirty way to hide menu elements for specific role. Be aware that this only hide the menu entry! the functionality will remain accessible by the url.  So it can be a security flaw&#8230; anyway, install the extension and choose a menu entry to customize.<br />
 Useful if you want to hide some admin menu links but step 6 is a better alternative&#8230;</p>
<h3>step 5 : create custom administration pages with views</h3>
<p>if you want to separate some items from admin/content/node to highlight it, use a view with<br />
 &#8211; style : table (with sortable fields in the style options)<br />
 &#8211; fields node: edit and node: delete link + exposed filter(s)<br />
 &#8211; access to your specific user role. <br />
 &#8211; add page display and a menu entry</p>
<h3>step 6 : create a specific menu for admin purposes</h3>
<p>with a link to content/list, content/add &#8230; and all others site specific needs.<br />
 show it only for your role.<br />
 useful if you don&#8217;t want to grant the &#8220;administer nodes&#8221; permission.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/provide-a-clean-back-end-interface-for-your-client/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multisite setup</title>
		<link>http://www.citytree.be/blog/multisite-setup</link>
		<comments>http://www.citytree.be/blog/multisite-setup#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:44:23 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=450</guid>
		<description><![CDATA[The goal is to have a single drupal core to handle multiple sites / instances 1. installation install drupal as usual 2. directory structure inside site/ create a directory for each of your site named yoursitename.tld inside yoursitename.tld create directories for the specific modules and themes (you can then split it in contrib/ and custom/) [...]]]></description>
			<content:encoded><![CDATA[<p><em>The goal is to have a single drupal core to handle multiple sites / instances </em></p>
<h3>1. installation</h3>
<p>install drupal as usual</p>
<h3>2. directory structure</h3>
<p>inside site/ create a directory for each of your site named yoursitename.tld</p>
<p>inside yoursitename.tld create</p>
<ul>
<li>directories for the specific modules and themes (you can then split it in contrib/ and custom/) + files</li>
<li>copy settings.php and adapt db site&#8217;s specific values </li>
<li>put the modules used by every sites (cck, pathauto, devel, admin_menu, &#8230;) in site/all/modules </li>
</ul>
<h3>3. virtual host</h3>
<ul>
<li> DocumentRoot is the same for every sites : that&#8217;s where your installation sits (/var/www/drupal6 for example) </li>
<li>ServerName is the name of your site (!), drupal will use it to map the name of your site.tld with the site/ directory structure </li>
</ul>
<h3>4. pros</h3>
<ul>
<li>update core / shared modules only once <br />
 =&gt; you can create a <a href="http://drupal.org/node/453354">script to run cron</a> for all sites </li>
<li>quick creation of new sites </li>
</ul>
<h3>5. cons</h3>
<ul>
<li>on core issues, all sites are down&#8230; </li>
<li>high load of the server</li>
<li>you have to manually run update.php on every site (it can take times when a site may be + &#8211; down) </li>
</ul>
<p><em><a href="http://drupal.org/getting-started/6/install/multi-site">more info on drupal&#8217;s website</a> <br />
 </em></p>
<h3>6. sharing databases / tables</h3>
<p>it&#8217;s possible to share data between sites.</p>
<p>example:   if you want sitea and siteb using the same users, but with different content, you will have</p>
<ul>
<li>3 databases for the 2 sites, (1 for content sitea / siteb, 1 for shared tables) </li>
<li>shared tables (users, sessions,&#8230;) must be have the prefix of the shared database in <a href="http://api.drupal.org/api/file/sites/default/default.settings.php/6/source">settings.php / Database area</a> ( <em>shared_db.</em> with . for sql join)</li>
<li>a default prefix (indicated only once) for other tables </li>
<p>$db_prefix = array(      &#8216;default&#8217; =  &#8221;,  &#8216;users&#8217; =  &#8216;shared_db.&#8217;,   &#8216;role&#8217; =  &#8216;shared_db.&#8217;,    &#8216;sessions&#8217; =  &#8216;shared_db.&#8217;,       );</p>
<li>to permit a same user login on sitea AND siteb, install <a href="http://drupal.org/project/singlesignon">single sign on module</a> </li>
</ul>
<blockquote><p><strong>note </strong>: it&#8217;s also possible to have only 1 databases with same prefixes for common table and different prefixes for the other ones (this time prefix without . &#8217;cause we use the same db)</p>
</blockquote>
<p><em><a href="http://drupal.org/node/291373">more info on drupal website</a> </em></p>
<blockquote><p><strong>note </strong>: you can also take a look, at <a href="http://gotdrupal.com/videos/multisites-vs-multiple-sites">this video</a> with interesting server settings</p>
</blockquote>
<p>=&gt; an other interresting module (not tested yet) : <a href="http://drupal.org/project/domain">Domain </a></p>
<p>edit : I&#8217;ve test it on several projects and Domain module is awesome !! nice documentation, incredible functionalities , powerful hooks&#8230; a really must have module for multisite management !!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/multisite-setup/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image handling</title>
		<link>http://www.citytree.be/blog/image-handling</link>
		<comments>http://www.citytree.be/blog/image-handling#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:40:13 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=452</guid>
		<description><![CDATA[filesystem public : /sites/default/files every files are downloadable, they can be hidden via permissions but accessible through file system private : /system/files drupal control file download and show 403 if no permission cck imagefield D7core Depends on filefield D7core :  ajax uploads -&#62; restriction on image : type / size / resolution -&#62; features : [...]]]></description>
			<content:encoded><![CDATA[<h2>filesystem</h2>
<p><strong>public</strong> : /sites/default/files</p>
<p style="padding-left: 30px;">every files are downloadable, they can be hidden via permissions but accessible through file system</p>
<p><strong>private</strong> : /system/files</p>
<p style="padding-left: 30px;">drupal control file download and show 403 if no permission</p>
<p><br class="spacer_" /></p>
<h2>cck</h2>
<p><a href="http://drupal.org/project/imagefield">imagefield</a> <em>D7core</em></p>
<p style="padding-left: 30px;">Depends on <a href="http://drupal.org/project/filefield">filefield</a> <em>D7core</em> :  ajax uploads</p>
<p style="padding-left: 60px;">-&gt; restriction on image : type / size / resolution<br />
 -&gt; features : alt / title tags with tokens, default image<br />
 -&gt; display : image, link, path, IMAGECACHE preset</p>
<p><strong> further config / features</strong></p>
<p style="padding-left: 30px;">-&gt; <a href="http://www.drupaler.co.uk/blog/drupal-6x-and-ubuntu-804-hardy/448">&#8220;full&#8221; gd library</a> (not default on debian like)  <em>or <a href="http://cumu.li/2008/5/13/recompiling-php5-with-bundled-support-for-gd-on-ubuntu">this link</a></em><br />
 -&gt; uploadprogress install it with pear  [pecl install uploadprogress]<br />
 -&gt; max file size (htaccess or php.ini) :  [post_max_size = 100M] and [upload_max_filesize = 2M] directive</p>
<p><a href="http://drupal.org/project/imagecache"> imagecache</a> <em>D7core</em> : presets on cck + views</p>
<p>Depends on <a href="http://drupal.org/project/imageapi">imageapi</a> <em>D7core</em> and gd library [aptitude install php5-gd]<br />
 call with [print theme('imagecache', 'imagecache_preset_name', 'original_image_filepath', "alt_tag", "title_tag", "custom_attributes_as_class_or_id"); ]</p>
<p style="padding-left: 30px;">-&gt; play with size, rotation, + effects &#8211; desaturate (bw conversion) &#8211; sharpening<br />
 -&gt; create image on demand. if file doesn&#8217;t exist, image cache create it</p>
<p><a href="http://drupal.org/project/imagecache_actions"> imagecache_actions</a> <em>D7 ?</em></p>
<p style="padding-left: 30px;">-&gt; &#8220;<strong>layer style</strong>&#8220;  : Watermark (place an image over a source picture), Background, text overlay, canvas manipulation<br />
 -&gt; <strong>colors</strong> : colorize image, invert, darken / lighten<br />
 -&gt; <strong>feature </strong>: rounded corners, alpha blending, file format switcher</p>
<p><a href="http://drupal.org/project/imagecache_profiles"> imagecache_profiles</a> <br />
 <a href="http://drupal.org/project/imagecrop">imagecrop</a> / <a href="http://drupal.org/project/imagefield_crop">imagefield_crop</a> :  js resizing <br />
 <a href="http://drupal.org/project/imagefield_extended">imagefield_extended</a> : Add additional data to images other than the default Description, Title and Alt.<br />
 <a href="http://drupal.org/project/image_fupload">image_fupload</a> : upload multiple images with one simple click</p>
<h2>bonus :</h2>
<p><strong> image integration with wysiwyg</strong><a href="http://drupal.org/project/wysiwyg"></a></p>
<p style="padding-left: 30px;"><a href="http://drupal.org/project/wysiwyg">wysiwyg </a> <em>D7ready</em> + tinymce (see wysiwyg config) + <a href="http://drupal.org/project/imce">imce </a>D7ready + <a href="http://drupal.org/project/imce_wysiwyg">imce_wysiwyg bridge</a> D7?<br />
 activate in &#8220;button and plugin&#8221; &gt; imce (wysiwyg &gt; tinymce config)</p>
<p>alternative to imce <a href="http://drupal.org/project/filefield_insert">filefield_insert</a> &#8220;use a cck filefield for uploading images and send the image to the RTE&#8221;</p>
<p><a href="http://drupal.org/project/lightbox2">lightbox</a> integration and plenty of gallery modules&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/image-handling/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update fields with &#8220;replace&#8221; command</title>
		<link>http://www.citytree.be/blog/update-fields-with-replace-command</link>
		<comments>http://www.citytree.be/blog/update-fields-with-replace-command#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:40:12 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=444</guid>
		<description><![CDATA[when you move your wordpess blog into another location, youy need to update fields in mysql]]></description>
			<content:encoded><![CDATA[<p>when you move your wordpess blog into another location, youy need to update fields in mysql</p>
<div id="wpshdo_12" class="wp-synhighlighter-outer"><div id="wpshdt_12" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_12"></a><a id="wpshat_12" class="wp-synhighlighter-title" href="#codesyntax_12"  onClick="javascript:wpsh_toggleBlock(12)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_12" onClick="javascript:wpsh_code(12)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_print(12)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_12" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">UPDATE wp_postmeta <span class="kw4">SET</span> meta_value <span class="sy0">=</span> replace<span class="br0">&#40;</span>meta_value<span class="sy0">,</span> <span class="st_h">'http://localhost/yoursite'</span><span class="sy0">,</span><span class="st_h">'http://www.yoursite.com'</span><span class="br0">&#41;</span>;
UPDATE wp_options <span class="kw4">SET</span> option_value <span class="sy0">=</span> replace<span class="br0">&#40;</span>option_value<span class="sy0">,</span> <span class="st_h">'http://localhost/yoursite'</span><span class="sy0">,</span><span class="st_h">'http://www.yoursite.com'</span><span class="br0">&#41;</span>;
UPDATE wp_posts <span class="kw4">SET</span> guid <span class="sy0">=</span> replace<span class="br0">&#40;</span>guid<span class="sy0">,</span> <span class="st_h">'http://localhost/yoursite/'</span><span class="sy0">,</span><span class="st_h">'http://www.yoursite.com'</span><span class="br0">&#41;</span>;
UPDATE wp_posts <span class="kw4">SET</span> post_content <span class="sy0">=</span> replace<span class="br0">&#40;</span>post_content<span class="sy0">,</span> <span class="st_h">'http://localhost/yoursite'</span><span class="sy0">,</span><span class="st_h">'http://www.yoursite.com'</span><span class="br0">&#41;</span>;</pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/update-fields-with-replace-command/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Concat multiple rows in one</title>
		<link>http://www.citytree.be/blog/concat-multiple-rows-in-one</link>
		<comments>http://www.citytree.be/blog/concat-multiple-rows-in-one#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:37:47 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=441</guid>
		<description><![CDATA[I will take an example to explain this tip. imagine we want to export our drupal users with their roles. if a user has 3 roles, the result of the join query will be 3 rows for him. Using GROUP_CONCAT will give us all roles in one single row. notice here the GROUP BY u.uid [...]]]></description>
			<content:encoded><![CDATA[<p>I will take an example to explain this tip.</p>
<p>imagine we want to export our drupal users with their roles. if a user has 3 roles, the result of the join query will be 3 rows for him.</p>
<p>Using GROUP_CONCAT will give us all roles in one single row.</p>
<div id="wpshdo_13" class="wp-synhighlighter-outer"><div id="wpshdt_13" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_13"></a><a id="wpshat_13" class="wp-synhighlighter-title" href="#codesyntax_13"  onClick="javascript:wpsh_toggleBlock(13)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_13" onClick="javascript:wpsh_code(13)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_print(13)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_13" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">SELECT u.<span class="me1">uid</span><span class="sy0">,</span> u.<span class="kw1">name</span><span class="sy0">,</span> u.<span class="me1">mail</span><span class="sy0">,</span>
 GROUP_CONCAT<span class="br0">&#40;</span>DISTINCT r.<span class="kw1">name</span> SEPARATOR <span class="st_h">'/'</span><span class="br0">&#41;</span> as roles
from users u
 inner join users_roles ur on ur.<span class="me1">uid</span> <span class="sy0">=</span> u.<span class="me1">uid</span>
 inner join role r using<span class="br0">&#40;</span>rid<span class="br0">&#41;</span>
 GROUP BY u.<span class="me1">uid</span></pre></div></div>
<p>notice here the GROUP BY u.uid (otherwise all users will be concatenated in 1 row).</p>
<p>see <a href="http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat" target="_blank">the syntax of this function</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/concat-multiple-rows-in-one/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sort query results in a particular order</title>
		<link>http://www.citytree.be/blog/sort-query-results-in-a-particular-order</link>
		<comments>http://www.citytree.be/blog/sort-query-results-in-a-particular-order#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:37:06 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=439</guid>
		<description><![CDATA[another useful mysql tip is to sort result in a particular order (not asc or desc) imagine we have a table of animals, a field with the names and another with the type :  bird, dog and cat in our result we want to see all cats at first then birds then dogs we will [...]]]></description>
			<content:encoded><![CDATA[<p>another useful mysql tip is to sort result in a particular order (not asc or desc)</p>
<p>imagine we have a table of animals, a field with the names and another with the type :  bird, dog and cat</p>
<p>in our result we want to see all cats at first then birds then dogs</p>
<p>we will use the ORDER BY FIELD(fieldname , &#8216;value1&#8242;, &#8216;value2&#8242;,&#8230;)</p>
<div id="wpshdo_14" class="wp-synhighlighter-outer"><div id="wpshdt_14" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_14"></a><a id="wpshat_14" class="wp-synhighlighter-title" href="#codesyntax_14"  onClick="javascript:wpsh_toggleBlock(14)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_14" onClick="javascript:wpsh_code(14)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_print(14)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_14" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">SELECT <span class="sy0">*</span> FROM animals
 ORDER BY FIELD<span class="br0">&#40;</span><span class="kw1">type</span><span class="sy0">,</span> <span class="st_h">'cat'</span><span class="sy0">,</span>bird<span class="st_h">','</span>dog<span class="st_h">')</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/sort-query-results-in-a-particular-order/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Order your nodes by most recent post OR comment date</title>
		<link>http://www.citytree.be/blog/order-your-nodes-by-most-recent-post-or-comment-date</link>
		<comments>http://www.citytree.be/blog/order-your-nodes-by-most-recent-post-or-comment-date#comments</comments>
		<pubDate>Fri, 02 Jul 2010 11:35:57 +0000</pubDate>
		<dc:creator>thomas</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.citytree.be/?p=437</guid>
		<description><![CDATA[Hello, ever wanted to sort your nodes by post or comment date like forums do ( last &#8220;action&#8221; first) ? you can do that easily with mysql and greatest select]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>ever wanted to sort your nodes by post or comment date like forums do ( last &#8220;action&#8221; first) ?</p>
<p>you can do that easily with mysql and greatest select</p>
<div id="wpshdo_15" class="wp-synhighlighter-outer"><div id="wpshdt_15" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_15"></a><a id="wpshat_15" class="wp-synhighlighter-title" href="#codesyntax_15"  onClick="javascript:wpsh_toggleBlock(15)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_15" onClick="javascript:wpsh_code(15)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_print(15)" title="Print code"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.citytree.be/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.citytree.be/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_15" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;">SELECT n.<span class="me1">nid</span><span class="sy0">,</span> title<span class="sy0">,</span>
GREATEST<span class="br0">&#40;</span>n.<span class="me1">created</span><span class="sy0">,</span> last_comment_timestamp<span class="br0">&#41;</span> as dateup
&nbsp;
FROM node n
INNER JOIN `node_comment_statistics` using<span class="br0">&#40;</span>nid<span class="br0">&#41;</span>
&nbsp;
order by dateup desc</pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.citytree.be/blog/order-your-nodes-by-most-recent-post-or-comment-date/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

