<?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>Tristan Media Blog &#187; Drupal5</title>
	<atom:link href="http://blog.tristanmedia.com/category/drupal5/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tristanmedia.com</link>
	<description>One can never have enough scripting languages: Notes on Perl, PHP, and Ruby</description>
	<lastBuildDate>Sun, 11 Jul 2010 01:10:53 +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>Custom Drupal Modules &#8211; creating filters for Views</title>
		<link>http://blog.tristanmedia.com/2008/07/custom-drupal-modules-creating-filters-for-views/</link>
		<comments>http://blog.tristanmedia.com/2008/07/custom-drupal-modules-creating-filters-for-views/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 20:40:45 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Drupal5]]></category>
		<category><![CDATA[drupal modules]]></category>
		<category><![CDATA[drupal views]]></category>

		<guid isPermaLink="false">http://blog2.tristanmedia.com/2008/07/custom-drupal-modules-creating-filters-for-views/</guid>
		<description><![CDATA[Continuing my exploration of custom modules and views, here is my code for allowing view builders to filter entries based on a status field, say "special offers", that is represented in our module's database table by an integer with 1 for true or 0 for false. Add this key to your array entry for a [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing my exploration of custom modules and views, here is my code for allowing view builders to filter entries based on a status field, say "special offers", that is represented in our module's database table by an integer with 1 for true or 0 for false.</p>
<p>Add this key to your array entry for a table, at the same level as the "join" key.  See my <a href="/2008/06/custom-drupal-modules-and-views/">earlier post</a> for how the rest of the array works.</p>
<p></p>
<p>In this case, the database column is called "is_special_offer".  The keys you should supply are discussed <a href="http://drupal.org/node/99794">here</a> in the Views handbook.</p>
<div class="wp_syntax">
<div class="code">
<pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">&#8216;filters&#8217;</span> <span style="color: #339933;">=></span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">&#8216;is_special_offer&#8217;</span> <span style="color: #339933;">=></span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&#8216;name&#8217;</span> <span style="color: #339933;">=></span> <span style="color: #0000ff;">&#8216;Product: Is Special Offer&#8217;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&#8216;operator&#8217;</span> <span style="color: #339933;">=></span> <span style="color: #0000ff;">&#8216;views_handler_operator_eqneq&#8217;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&#8216;list&#8217;</span> <span style="color: #339933;">=></span> <span style="color: #0000ff;">&#8216;views_handler_operator_yesno&#8217;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&#8216;list-type&#8217;</span> <span style="color: #339933;">=></span> <span style="color: #0000ff;">&#8216;select&#8217;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&#8216;help&#8217;</span> <span style="color: #339933;">=></span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&#8216;Show only Special Offers&#8217;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tristanmedia.com/2008/07/custom-drupal-modules-creating-filters-for-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Drupal Modules and Views</title>
		<link>http://blog.tristanmedia.com/2008/06/custom-drupal-modules-and-views/</link>
		<comments>http://blog.tristanmedia.com/2008/06/custom-drupal-modules-and-views/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 17:53:51 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Drupal5]]></category>
		<category><![CDATA[drupal modules]]></category>
		<category><![CDATA[drupal views]]></category>

		<guid isPermaLink="false">http://blog2.tristanmedia.com/2008/06/custom-drupal-modules-and-views/</guid>
		<description><![CDATA[I'm working with a client on a Drupal site where another programmer has implemented several custom content types via a module, not CCK. I'm researching how to integrate this with the Views module, and found this useful information so far. http://drupal.org/handbook/modules/views/api http://drupal.org/node/148456 The hook of note seems to be hook_views_tables to get the view editing [...]]]></description>
			<content:encoded><![CDATA[<p>I'm working with a client on a Drupal site where another programmer has implemented  several custom content types via a module, not <a href="http://drupal.org/project/cck">CCK</a>.  I'm researching how to integrate this with the <a href="http://drupal.org/project/views">Views</a> module, and found this useful information so far.</p>
<ul>
<li><a href="http://drupal.org/handbook/modules/views/api">http://drupal.org/handbook/modules/views/api</a></li>
<li><a href="http://drupal.org/node/148456">http://drupal.org/node/148456</a></li>
</ul>
<p>The hook of note seems to be hook_views_tables to get the view editing interface to know about the columns in our custom table.</p>
<p>Here is the start of a function to return the information to the Views module.  In this example we use product_id as the primary key of our table, which is the same as the node's nid.  This only exposes the name of the product to the view, but more columns and tables will be added later.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// hook to tell views about our tables</span>
<span style="color: #000000; font-weight: bold;">function</span> mymodule_views_tables<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$tables</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mymodule_product'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'mymodule_product'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'join'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'left'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'table'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'node'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'field'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'nid'</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'right'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'field'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'product_id'</span>
      <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'fields'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Product: Name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'sortable'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$tables</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.tristanmedia.com/2008/06/custom-drupal-modules-and-views/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
