<?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>Misty thoughts &#187; drupal</title>
	<atom:link href="http://blog.kfirbreger.com/tag/drupal/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kfirbreger.com</link>
	<description></description>
	<lastBuildDate>Tue, 13 Jul 2010 07:44:30 +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>Setting up Solr for Drupal under tomcat</title>
		<link>http://blog.kfirbreger.com/2010/07/13/setting-up-solr-for-drupal-under-tomcat/</link>
		<comments>http://blog.kfirbreger.com/2010/07/13/setting-up-solr-for-drupal-under-tomcat/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 06:37:56 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=263</guid>
		<description><![CDATA[Disclaimer: This method will probably not work for all servers running tomcat, it is more a personal guide then a general one. Solr is a "popular, blazing fast open source enterprise search platform from the Apache Lucene project". Drupal search has traditionally been less then adequate. Using Solr to index and search you Drupal site [...]]]></description>
			<content:encoded><![CDATA[<p>Disclaimer: This method will probably not work for all servers running tomcat, it is more a personal guide then a general one.</p>
<p>Solr is a "popular, blazing fast open source enterprise search platform from the Apache Lucene project". Drupal search has traditionally been less then adequate. Using Solr to index and search you Drupal site is therefore quite helpful.</p>
<p>To start, download the Solr package (<a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/">link</a>) and the Solr drupal module (<a href="http://drupal.org/project/apachesolr">link</a>). the current standard distribution is Solr 1.4 and Drupal 6.<br />
Unarchive the tar files in a location that is reachable from your server.</p>
<p>We will assume that tomcat is installed in <code>/opt/tomcat</code></p>
<p>In the Solr package there is an example application. That is the Solr application we are going to use. If you can write your own, you probably don't need this tutorial.</p>
<p><strong>Step 1:</strong><br />
Copy the example application, found in the solr package under <code>example/webapps</code> to the tomecat webapps folder which should be <code>/opt/tomcat/webapps</code>. when copying the file rename it to something other the solr. this will enable you to have multiplie solr installations running under one Tomcat container. We will assume the app is renamed <code>new_solr_inst</code>. If you are in the tomcat root folder the command should like like this:<br />
<code>cp /path/to/solr/package/apache-solr-1.4.0/apache-solr-1.4.0/example/webapps/solr.war webapps/new_solr_inst.war</code></p>
<p>Tomcat will pick up the war file and open it automatically after a restart.</p>
<p><strong>Step 2:</strong><br />
In the tomcat root folder create a folder to hold your Solr configuration and data.<br />
<code>mkdir new_solr_inst</code><br />
Copy the example app configuration into that folder<br />
<code>cp -R /path/to/solr/package/apache-solr-1.4.0/apache-solr-1.4.0/example/solr/* new_solr_inst</code></p>
<p><strong>Step 3:</strong><br />
You need to replace the original <code>schema.xml</code> and <code>solrconfig.xml</code> with the ones provided by the drupal module. Copy these two files to your Solr configuration folder. Assuming you are currently at the tomcat root folder<br />
<code>cp /path/to/solr/module/schema.xml new_solr_inst/conf</code><br />
<code>cp /path/to/solr/module/solrconfig.xml new_solr_inst/conf</code><br />
The Solr app is now ready for use.</p>
<p><strong>Step 4:</strong><br />
The last step is needed to inform Tomcat about the app and its settings. Go to <code>conf/Catalina/localhost</code> and create the file <code>new_solr_inst.xml</code>. In that file fill the following content:</p>
<div id="_mcePaste"><code>&lt;Context docBase="/opt/tomcat/webapps/new_solr_inst.war" debug="0" privileged="true" allowLinking="true" crossContext="true"&gt;</code></div>
<div id="_mcePaste"><code>&lt;Environment name="solr/home" type="java.lang.String" value="/opt/tomcat/new_solr_inst" override="true" /&gt;</code></div>
<div id="_mcePaste"><code>&lt;/Context&gt;</code></div>
<p><strong>Step 5:</strong><br />
You need to restart tomcat<br />
<code>/opt/tomcat/bin/shutdown.sh</code><br />
<code>/opt/tomcat/bin/startup.sh</code><br />
And your Solr should be running. There are three tests we can use to check everything went well.</p>
<ul>
<li>Tomcat has opened the war file. There is now a folder <code>new_solr_inst</code> in the <code>webapps</code> folder of Tomcat.</li>
<li>Solr has made a <code>data</code> directory in the Solr home folder (that is <code>/opt/tomcat/new_solr_inst</code>)</li>
<li>In your browser go to the Solr app <code>http://domain:tomcat_port/new_solr_inst</code> and you should see a welcome screen</li>
</ul>
<p>If all is well you are ready to combine this Solr installation with your Drupal</p>
<p><strong>Step 6:</strong><br />
Activate the Apache-Solr module and go to the Solr module settings page <code>admin/settings/apachesolr</code><br />
Assuming tomcat and drupal are running on the same server fill in <code>localhost</code> as the host name, fill in the port tomcat is running on and solr path should be your app name in the tomcat webapps folder. In our case is it <code>new_solr_inst</code>.</p>
<p>Save the settings. Drupal should inform you that a connection is made with Solr</p>
<p>Notes</p>
<ul>
<li>It is not nessecary to put the app configuration in the Tomcat root folder. you can probably (though I have not tested this) place it anywhere you want. you do need to make sure that the environment tag in the Tomact configuration file (the one in the <code>conf/Catalina/localhost</code> folder) is pointing to the right place.</li>
<li>If you make changes to the schema you may need to dump all the indices Solr has made. you can do this via the Drupal admin interface for the Solr module.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/07/13/setting-up-solr-for-drupal-under-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting session ID in Drupal 6</title>
		<link>http://blog.kfirbreger.com/2010/02/25/getting-session-id-in-drupal-6/</link>
		<comments>http://blog.kfirbreger.com/2010/02/25/getting-session-id-in-drupal-6/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 20:49:22 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[guide]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=257</guid>
		<description><![CDATA[Drupal saves its sessions in the sessions table. One can always query they table to get the session ID. There is however a faster way. If the user is logged it, the session id can be found with the following code: global $user; $user->sid; In any case the session id can also be read from [...]]]></description>
			<content:encoded><![CDATA[<p>
Drupal saves its sessions in the sessions table. One can always query they table to get the session ID. There is however a faster way.<br />
If the user is logged it, the session id can be found with the following code:</p>
<pre>
global $user;
$user->sid;
</pre>
<p><span>In any case the session id can also be read from the cookie:</span></p>
<pre>
$_COOKIE[session_name()];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/02/25/getting-session-id-in-drupal-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Theming a form in Drupal 6</title>
		<link>http://blog.kfirbreger.com/2010/02/23/theming-a-form-in-drupal-6/</link>
		<comments>http://blog.kfirbreger.com/2010/02/23/theming-a-form-in-drupal-6/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 11:07:19 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[Me]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[form api]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[theming]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/2010/02/23/theming-a-form-in-drupal-6/</guid>
		<description><![CDATA[Form theming in drupal 6 is quite flexible. One of the nicest tricks is the ability to theme the form in stages. Calling drupal_render on a part of the form will not only return the rendered version of it, but it will also mark that part as rendered so that when you call the final [...]]]></description>
			<content:encoded><![CDATA[<p>Form theming in drupal 6 is quite flexible. One of the nicest tricks is the ability to theme the form in stages. Calling drupal_render on a part of the form will not only return the rendered version of it, but it will also mark that part as rendered so that when you call the final drupal_render over the whole form, it will not re-render the parts already rendered.</p>
<p>Remember that in order for the form to function correctly there are some hidden fields in every form that must be added to the form. Also drupal needs to generate the form tag. Therefore it is my advise, after doing the custom rendering of the parts you want, add a general render of the form. this will reduce the chance of problems with form submission.</p>
<p>Special thanks to Rolf van de Krol, for this tip.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/02/23/theming-a-form-in-drupal-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to truly disable drupal cache</title>
		<link>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/</link>
		<comments>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/#comments</comments>
		<pubDate>Fri, 29 May 2009 10:26:05 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[guide]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=168</guid>
		<description><![CDATA[Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain. If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>
Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain.</p>
</div>
<div>
<p>
If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not too. the developer module even makes it quite easy to do. However for me, and I am quite sure to quite a lot of other people it is not that clear.
</p>
</div>
<div>
<p>"Wait", you might say. "Drupal has a disable cache setting". You would be right to say that. Only it doesn't completely disable the cache, only part of the cache, namely the page caching. To truly disable cache you need to do a bit of a hacking to the cache code. Yes I know they say to never hack core (cache is part of the core drupal release). for me this was worth it. I figure as long as you remember its there and don't use it in production you should be fine. The following piece of code needs to be added in <code>include/cache.inc</code>. There are two functions there that you need to edit:</p>
<ul>
<li><code>cache_get</code></li>
<li><code>cache_set</code></li>
</ul>
<p>In <code>cache_get</code> place the code right after the <code>global $user</code>. In <code>cache_set</code>  place it at the start of the function. Here is the code that you need to add.<br />
<code><br />
if(variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) {<br />
    return 0;<br />
}<br />
</code><br />
Kudos for this hack goes to Rolf van der Krol. Cheers mate.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
