<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>ndiv0</title>
	<atom:link href="http://ndiv0.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ndiv0.wordpress.com</link>
	<description>Learning stuff</description>
	<lastBuildDate>Tue, 21 Jun 2011 15:48:56 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ndiv0.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>ndiv0</title>
		<link>http://ndiv0.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ndiv0.wordpress.com/osd.xml" title="ndiv0" />
	<atom:link rel='hub' href='http://ndiv0.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Update a view using AJAX in Drupal 6</title>
		<link>http://ndiv0.wordpress.com/2010/07/27/update-a-view-using-ajax-in-drupal-6/</link>
		<comments>http://ndiv0.wordpress.com/2010/07/27/update-a-view-using-ajax-in-drupal-6/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 14:06:03 +0000</pubDate>
		<dc:creator>ndiv0</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ndiv0.wordpress.com/?p=55</guid>
		<description><![CDATA[You have an AJAX view with pagination and exposed filter form, embedded inside a page and you want to update the view using AJAX to reflect some user interaction in that page. Updating the view is pretty easy but the problems start when you click on a pager link or try the filter form after the view [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndiv0.wordpress.com&amp;blog=15235&amp;post=55&amp;subd=ndiv0&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">You have an AJAX view with pagination and exposed filter form, embedded inside a page and you want to update the view using AJAX to reflect some user interaction in that page.</div>
<p>Updating the view is pretty easy but the problems start when you click on a pager link or try the filter form after the view is updated. The Javascript functionality of the view is lost and the URL used by the pager is now the URL of the original AJAX request.</p>
<p>After a lot of debugging I found out that in order to properly update a view using AJAX you will need to take care of two small things:</p>
<ol>
<li>Override the view&#8217;s path before you generate its content</li>
<li>In the page, call <em>Drupal.attachBehaviors </em>after you replace the content of the view<em>.</em> This will initialize the javascript functionality of the view.</li>
</ol>
<p>There are a lot of tutorials on the net about embedding and updating a view if you want more details on that, so I&#8217;ll just post a small example in order to clarify the context of the two points presented above.</p>
<p>In your module:</p>
<pre>// Define the URL for the AJAX call (http://api.drupal.org//api/function/hook_menu/6)
function MODULE_menu() {
  $items = array();

  $items['ACTION_URL'] = array(
    'title' =&gt; 'Some title',
    'page callback' =&gt; 'MODULE_process_ajax_call',
    // Let's assume you will need two arguments in the processing function
    'page arguments' =&gt; array(1, 2),
    'access callback' =&gt; 'MODULE_check_access',
    'type' =&gt; MENU_CALLBACK,
  );

  return $items;
}

// Access callback, for this example allow anyone to access the 'ACTION_URL'
function MODULE_check_access() {
  return TRUE;
}

// AJAX callback function
function MODULE_process_ajax_call($arg1, $arg2) {
  //do the work here and then render the view

  $view = views_get_view('VIEW_NAME');
  $view-&gt;set_display('default');
  // set the view arguments here, if needed
  //$view-&gt;set_arguments( array( 'VIEW', 'ARGUMENTS') );

  // Override the view path, otherwise the path will be 'ACTION_URL'
  $view-&gt;override_path = 'views/ajax';
  $output = $view-&gt;preview();

  return drupal_json(array('view_output' =&gt; $output));
}<span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:small;"><span style="line-height:19px;white-space:normal;">
</span></span></pre>
<p>In the page:</p>
<pre>&lt;div id='view-container'&gt;
  &lt;?php print views_embed_view('VIEW_NAME', 'default'); ?&gt;
&lt;/div&gt;

&lt;script type='text/javascript'&gt;
if(Drupal.jsEnabled) {
  var ajax_result_callback = function(data) {
    var result = Drupal.parseJson(data);
    jQuery('#view-container').html(result.view_output);
    Drupal.attachBehaviors('#view-container'); //Don't forget this !!!
  }

  function do_ajax_call(arg1, arg2) {
    jQuery.get('&lt;?php print $base_url?&gt;/ACTION_URL/'+arg1+'/'+arg2, 
                null, ajax_result_callback);
    // preventing entire page from reloading
    return false;
  }
}
&lt;/script&gt;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndiv0.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndiv0.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndiv0.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndiv0.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ndiv0.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ndiv0.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ndiv0.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ndiv0.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndiv0.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndiv0.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndiv0.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndiv0.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndiv0.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndiv0.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndiv0.wordpress.com&amp;blog=15235&amp;post=55&amp;subd=ndiv0&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ndiv0.wordpress.com/2010/07/27/update-a-view-using-ajax-in-drupal-6/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/339c49fc703afcab19bed1da1e393df3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ndiv0</media:title>
		</media:content>
	</item>
		<item>
		<title>Drupal date exposed filter &#8220;illegal choice&#8221; error</title>
		<link>http://ndiv0.wordpress.com/2010/07/16/drupal-date-exposed-filter-illegal-choice-error/</link>
		<comments>http://ndiv0.wordpress.com/2010/07/16/drupal-date-exposed-filter-illegal-choice-error/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 09:07:05 +0000</pubDate>
		<dc:creator>ndiv0</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ndiv0.wordpress.com/?p=33</guid>
		<description><![CDATA[In Drupal 6 a view with a date exposed filter having the &#8216;Remember&#8217; option set will generate an &#8216;illegal choice&#8217; error. The cause of the problem is described here http://drupal.org/node/447868#comment-2758586 When the exposed form is reloaded, the value for the date field is incorrectly set as a string instead of an array. The solution I used [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndiv0.wordpress.com&amp;blog=15235&amp;post=33&amp;subd=ndiv0&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Drupal 6 a view with a date exposed filter having the &#8216;Remember&#8217; option set will generate an &#8216;illegal choice&#8217; error. The cause of the problem is described here <a title="External link to http://drupal.org/node/447868#comment-2758586" href="http://drupal.org/node/447868#comment-2758586" target="_blank">http://drupal.org/node/447868#comment-2758586</a></p>
<p>When  the exposed form is reloaded, the value for the date field is  incorrectly set as a string instead of an array.</p>
<p>The solution I used to fix this error was to  override the filter value just before submit, using hook_form_alter  inside my own module.</p>
<pre>function MODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  switch ($form_id) {
    case 'views_exposed_form':
      if($form_state['view']-&gt;name == 'YOUR_VIEW_NAME') {
        $value = $form_state['input']['YOUR_DATE_FILTER']['value'];
        if(is_string($value)) {
           $regexp = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\s([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
           if(preg_match($regexp, $value, $matches)) {
            $form_state['input']['YOUR_DATE_FILTER']['value'] =
                array('year' =&gt; $matches[1],
                         'month' =&gt; intval($matches[2]),
                         'day' =&gt; intval($matches[3]),
                         'hour' =&gt; intval($matches[4]),
                         'minute' =&gt; intval($matches[5]),
                         'second' =&gt; intval($matches[6]));
           }
        }
    }
    break;

    default:
    break;
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndiv0.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndiv0.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndiv0.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndiv0.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ndiv0.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ndiv0.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ndiv0.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ndiv0.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndiv0.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndiv0.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndiv0.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndiv0.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndiv0.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndiv0.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndiv0.wordpress.com&amp;blog=15235&amp;post=33&amp;subd=ndiv0&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ndiv0.wordpress.com/2010/07/16/drupal-date-exposed-filter-illegal-choice-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/339c49fc703afcab19bed1da1e393df3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ndiv0</media:title>
		</media:content>
	</item>
		<item>
		<title>Start learning Lisp</title>
		<link>http://ndiv0.wordpress.com/2006/01/19/start-learning-lisp/</link>
		<comments>http://ndiv0.wordpress.com/2006/01/19/start-learning-lisp/#comments</comments>
		<pubDate>Thu, 19 Jan 2006 13:36:42 +0000</pubDate>
		<dc:creator>ndiv0</dc:creator>
				<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ndiv0.wordpress.com/2006/01/19/start-learning-lisp/</guid>
		<description><![CDATA[Finally I started to learn some secret alien techology, Lisp I think &#8220;Common Lisp: A Gentle Introduction to Symbolic Computation&#8221; is a good book to start with. It is available for free here. I&#8217;ll post some notes, to help me review what I&#8217;ve learned.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndiv0.wordpress.com&amp;blog=15235&amp;post=4&amp;subd=ndiv0&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Finally I started to learn some secret alien techology, Lisp <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I think &#8220;<strong>Common Lisp: A Gentle Introduction to Symbolic Computation</strong>&#8221; is a good book to start with. It is available for free <a href="http://www.cs.cmu.edu/~dst/LispBook/">here</a>.</p>
<p>I&#8217;ll post some notes, to help me review what I&#8217;ve learned.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ndiv0.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ndiv0.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ndiv0.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ndiv0.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ndiv0.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ndiv0.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ndiv0.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ndiv0.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ndiv0.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ndiv0.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ndiv0.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ndiv0.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ndiv0.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ndiv0.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ndiv0.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ndiv0.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ndiv0.wordpress.com&amp;blog=15235&amp;post=4&amp;subd=ndiv0&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ndiv0.wordpress.com/2006/01/19/start-learning-lisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/339c49fc703afcab19bed1da1e393df3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ndiv0</media:title>
		</media:content>
	</item>
	</channel>
</rss>
