<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
 <title>Drupal High</title>
 <link>http://drupalhigh.onsugar.com</link>
 <description></description>
 <language>en</language>
 <atom:link href="http://drupalhigh.onsugar.com/tag/drupal/rss" rel="self" type="application/rss+xml" />
 <copyright>Copyright 1976-2012 Sugar Inc.  All rights reserved.</copyright>
<item>
 <title>Why I love going to DrupalCon</title>
 <link>http://drupalhigh.onsugar.com/Why-I-love-going-DrupalCon-14752299</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/Why-I-love-going-DrupalCon-14752299&quot;&gt;&lt;/a&gt;&lt;p&gt;Here&#039;s the story of me saving at least several hours of development work in a 5 minute chat...&lt;/p&gt;
&lt;p&gt;On the flight out to Chicago on Sunday, I was working on a webform addon module for a client (integrating with Exact Target if anyone cares). I got most of the way through it, but I definitely felt like I was doing some things &quot;the hard way&quot;.&lt;/p&gt;
&lt;p&gt;The next day, during the pre-conference training session lunch break - I grabbed a plate and plopped down at an open seat. Said &quot;hi&quot; to the guy sitting next to me. Nathan &quot;quicksketch&quot; Haug. Who maintains the webform module. Who is super nice and helpful, as many Drupallers are. He indulged my questions and gave me some tips on how to better architect my module.&lt;/p&gt;
&lt;p&gt;Hopefully this kind of story helps you convince your boss to send you to the next one! The return-on-investment is very real. These kinds of interactions are incredibly valuable, and happen all the time at conferences, summits and camps.&lt;/p&gt;
</description>
 <comments>http://drupalhigh.onsugar.com/Why-I-love-going-DrupalCon-14752299#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drupalcon">drupalcon</category>
 <category domain="http://drupalhigh.onsugar.com/tag/ROI">ROI</category>
 <category domain="http://drupalhigh.onsugar.com/tag/webform">webform</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drupal events">drupal events</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drupalcon chicago 2011">drupalcon chicago 2011</category>
 <pubDate>Mon, 07 Mar 2011 11:57:22 PST</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/Why-I-love-going-DrupalCon-14752299</guid>
</item>
<item>
 <title>using RewriteMap</title>
 <link>http://drupalhigh.onsugar.com/How-use-Apache-modrewrite-RewriteMap-directive-9626766</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/How-use-Apache-modrewrite-RewriteMap-directive-9626766&quot;&gt;&lt;/a&gt;&lt;p&gt;This is an Apache Directive that I&#039;ve never had to use before, but it came in very handy for a very specific problem.    &lt;/p&gt;
&lt;p&gt;There was already an apache redirect (&lt;a href=&quot;http://drupalhigh.onsugar.com/Rewrites-Redirects-2623083&quot;&gt;RewriteRule + RewriteCond&lt;/a&gt;) in place, but the destination URL was case sensitive! That&#039;s not normally a problem, but it was for an ad server, and the variables were coming in as uppercase, but needed to be lowercase after the redirect. Bad programming on the part of the ad server in my opinion, but we&#039;re not going to let that stop us! :)  &lt;/p&gt;
&lt;p&gt;RewriteMap to the rescue!  &lt;/p&gt;
&lt;p&gt;First off, the actual directive is a lot like a function definition, and it can only go in a config file or vhost, it&#039;s not allowed in a .htaccess file. Luckily the one we want to use is built in, so we just make it available with: &lt;/p&gt;
&lt;div style=&quot;font-size: 8pt; background-color: #ccf2fe; padding:5px; border:1px solid; margin: 5px 0px 5px 15px; white-space: pre;&quot;&gt;RewriteMap      lc int:tolower&lt;/div&gt;
&lt;p&gt;This makes the &quot;lc&quot; function is available in our rewrite rules. We start off with the condition and basic rule ...&lt;/p&gt;
&lt;div style=&quot;font-size: 8pt; background-color: #ccf2fe; padding:5px; border:1px solid; margin: 5px 0px 5px 15px; white-space: pre;&quot;&gt;
  # Send ads to new ad server&lt;br /&gt;
  RewriteCond %{HTTP_HOST} ^old\.ad\.server\.com$ [NC]&lt;br /&gt;
  RewriteRule ^.*site=([^/]+)/.*area=([^/]+)/.*$ http://newad.sever.net/ad/$1/$2 [R,L,NC]
&lt;/div&gt;
&lt;p&gt;To use the RewriteMap function in your RewriteRule just change the $N replacement to ${lc:$N}, and you&#039;re all set. So for example $1 becomes ${lc:$1}. In our example above, the new RewriteRule looks like this:&lt;/p&gt;
&lt;div style=&quot;font-size: 8pt; background-color: #ccf2fe; padding:5px; border:1px solid; margin: 5px 0px 5px 15px; white-space: pre;&quot;&gt;
  RewriteRule ^.*site=([^/]+)/.*area=([^/]+)/.*$ http://newad.server.net/ad/${lc:$1}/${lc:$2} [R,L,NC]
&lt;/div&gt;
</description>
 <comments>http://drupalhigh.onsugar.com/How-use-Apache-modrewrite-RewriteMap-directive-9626766#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/apache">apache</category>
 <category domain="http://drupalhigh.onsugar.com/tag/directive">directive</category>
 <category domain="http://drupalhigh.onsugar.com/tag/lowercase url">lowercase url</category>
 <pubDate>Fri, 30 Jul 2010 12:56:53 PDT</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/How-use-Apache-modrewrite-RewriteMap-directive-9626766</guid>
</item>
<item>
 <title>Sequential updates with SQL</title>
 <link>http://drupalhigh.onsugar.com/Sequential-updates-SQL-6215939</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/Sequential-updates-SQL-6215939&quot;&gt;&lt;/a&gt;&lt;p&gt;Oh no! A series of posts were uploaded to the server in reverse order!&lt;/p&gt;
&lt;p&gt;The site uses a view that sorts posts into chronological order (node created time). We can&#039;t change the view just to handle these errant posts. We could update all the node created times one at a time in the database, but there&#039;s just too many - it&#039;ll take all day!&lt;/p&gt;
&lt;p&gt;I knew it would be possible to fix this with a little SQL, but I&#039;ve never had to do something like this before. After some reading and research, this is what I came up with&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;background-color: #800000; color: #ffcc99;&quot;&gt;SET @rownum := 0;&lt;br /&gt;UPDATE node SET created = UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL (SELECT @rownum := @rownum + 1) MINUTE)) WHERE nid &amp;gt; 100 AND nid &amp;lt; 200 ORDER BY created DESC;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;There&#039;s a lot going on in this statement:&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;background-color: #800000; color: #ffcc99;&quot;&gt;SET @rownum := 0;&lt;/span&gt; initializes the rownum variable to 0.&lt;/p&gt;
&lt;p&gt;You can mostly ignore the date stuff - Drupal uses integer timestamps while MySQL prefers real Dates. My plan is to use the DATE_ADD() function to add ever larger amounts to the starting time (NOW()). This could be a lot simpler just leaving everything as integers, but I like the challenge :)&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;background-color: #800000; color: #ffcc99;&quot;&gt;INTERVAL (SELECT @rownum := @rownum + 1) MINUTE&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This is really the key part of the statement. We&#039;re doing a subselect right in the middle of the UPDATE statement. This causes rownum to be incremented by 1, and the new value returned, which is then used to update just this row. When the next row is updated, rownum will be incremented again, and so on. So when each node gets its created time updated, the first will be now(), the second now() + 1 minute, the third now() + 2 minutes, etc.&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;background-color: #800000; color: #ffcc99;&quot;&gt;WHERE nid &amp;gt; 100 AND nid &amp;lt; 200&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The where clause just specifies which nodes we&#039;re updating, nothing special but it is critical. Make sure you&#039;re only affecting the rows you want to update.&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;background-color: #800000; color: #ffcc99;&quot;&gt;ORDER BY created DESC&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This is the other key part. Ordering for updates works just like it does for select statements. All the rows are getting updated, this lets us specify in what order the updated happen.&lt;/p&gt;
&lt;p&gt;So now when we put it all together, the magic happens. The nodes were uploaded in reverse order, remember? That means when we sort by created time in descending order, we get the newest ones first - those are the ones that should be the oldest. So when the update happens, the newest node gets the oldest time, and second newest gets the second oldest, ... all the way until the oldest node gets the newest time.&lt;/p&gt;
&lt;p&gt;And so they end up with reversed created times, and the view will now show them in the correct order.&lt;/p&gt;
</description>
 <comments>http://drupalhigh.onsugar.com/Sequential-updates-SQL-6215939#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/mysql">mysql</category>
 <category domain="http://drupalhigh.onsugar.com/tag/SQL">SQL</category>
 <pubDate>Fri, 13 Nov 2009 14:14:58 PST</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/Sequential-updates-SQL-6215939</guid>
</item>
<item>
 <title>Drush beats CVS, part 2</title>
 <link>http://drupalhigh.onsugar.com/Drush-beats-CVS-part-2-3774018</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/Drush-beats-CVS-part-2-3774018&quot;&gt;&lt;/a&gt;&lt;p&gt;So it seems like a lot of people disagreed with my &lt;a href=&quot;http://drupalhigh.onsugar.com/3634132&quot;&gt;previous post&lt;/a&gt;! :) I should mention that I&#039;m not against CVS and the title may have been provocative, the &lt;a href=&quot;http://drupal.org/project/cvs_deploy&quot;&gt;cvs_deploy module&lt;/a&gt; works very well, and CVS and SVN are not mutually exclusive - you can have both in the same repository and they will happily ignore each other.&lt;/p&gt;
&lt;p&gt;But it got me to thinking, what am I missing? I use SVN repositories for the sites that I build. I use Drush to install the modules that I need and check for upgrades. The module upgrade process is slower for me since I like to know all the details of what changed first. So I&#039;m open to people letting me know how I could be working smarter, and how using the CVS respository could be making my life easier!&lt;/p&gt;
&lt;p&gt;I know the comments system at onSugar is not the greatest, feel free to email me via my Drupal contact form, and I&#039;ll post the responses.&lt;/p&gt;</description>
 <comments>http://drupalhigh.onsugar.com/Drush-beats-CVS-part-2-3774018#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/svn">svn</category>
 <category domain="http://drupalhigh.onsugar.com/tag/CVS">CVS</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drush">drush</category>
 <category domain="http://drupalhigh.onsugar.com/tag/cvs_deploy">cvs_deploy</category>
 <pubDate>Wed, 05 Aug 2009 12:14:27 PDT</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/Drush-beats-CVS-part-2-3774018</guid>
</item>
<item>
 <title>Drush beats CVS</title>
 <link>http://drupalhigh.onsugar.com/Drush-beats-CVS-3634132</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/Drush-beats-CVS-3634132&quot;&gt;&lt;/a&gt;&lt;p&gt;I had checked out a bunch of modules fron CVS, but then I realized that CVS checkouts don&#039;t come with all the info such as version numbers, so I wanted to delete them and replace them with real copies. I used Drush and Bash, and here&#039;s how I did it.&lt;/p&gt;
&lt;p&gt;Need to delete every CVS file from the sites/all/modules directory, and then replace each module with a fresh copy downloaded from drupal.org, and do it without ruining your SVN repository? &quot;What&#039;s the difference?&quot; you ask. Well, modules checked out directly from CVS don&#039;t get extra packaging info from drupal.org, and don&#039;t keep track of their own version numbers properly (you&#039;ll see a blank Version column on admin/build/modules).&lt;/p&gt;
&lt;p&gt;So by getting a fresh copy from drupal.org, you get a proper .info file, and a LICENSE.txt file added for you.    And it&#039;s a long module list? No problemo!&lt;/p&gt;
&lt;p&gt;Assumptions - you have Drush installed and you&#039;re working with a checkout of an SVN repository.&lt;/p&gt;
&lt;p&gt;cd to your modules directory, usually&lt;span style=&quot;color: #993300;&quot;&gt;&lt;code&gt;&lt;br /&gt;cd examplesite/sites/all/modules&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Update your modules to their latest versions - Drush is going to try and download the latest anyway, and you want them to match up.&lt;br /&gt;&lt;br /&gt;Tell Drush to grab fresh copies of modules from drupal.org with:&lt;br /&gt; &lt;span style=&quot;color: #993300;&quot;&gt;&lt;code&gt;find . -name CVS -depth 2 | sed &#039;s/\// /g&#039; | awk {&#039;print $2&#039;} | xargs drush dl&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;and watch the &quot;Project xxx downloaded to ...&quot; messages scroll by.&lt;/p&gt;
&lt;p&gt;Get rid of all the CVS files with &lt;span style=&quot;color: #993300;&quot;&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;span style=&quot;color: #993300;&quot;&gt;&lt;code&gt;&lt;br /&gt;find . -name CVS -prune -exec svn rm {} \;&lt;/code&gt;&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;Add all the new files (should just be a bunch of LICENSE.txt files) with &lt;br /&gt;&lt;span style=&quot;color: #993300;&quot;&gt;&lt;code&gt;svn status | grep &#039;^?&#039; | xargs svn add&lt;/code&gt;&lt;/span&gt; &lt;br /&gt;Then do a quick svn status - and you should see a bunch of Deletes on CVS files, Adding LICENSE.txt files, and Modifying any .info files&lt;br /&gt; &lt;br /&gt;Last, SVN commit the whole bunch! yay! &lt;br /&gt;&lt;span style=&quot;color: #993300;&quot;&gt;&lt;code&gt;svn commit -m &quot;removed old CVS tags, redownloaded modules from drupal.org&quot; .&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;--&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;edit: thanks to Joel for a better introduction&lt;/span&gt;&lt;/p&gt;</description>
 <comments>http://drupalhigh.onsugar.com/Drush-beats-CVS-3634132#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/svn">svn</category>
 <category domain="http://drupalhigh.onsugar.com/tag/CVS">CVS</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drush">drush</category>
 <category domain="http://drupalhigh.onsugar.com/tag/find">find</category>
 <category domain="http://drupalhigh.onsugar.com/tag/sed">sed</category>
 <category domain="http://drupalhigh.onsugar.com/tag/awk">awk</category>
 <pubDate>Thu, 30 Jul 2009 17:14:10 PDT</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/Drush-beats-CVS-3634132</guid>
</item>
<item>
 <title>update_sql is not my friend</title>
 <link>http://drupalhigh.onsugar.com/updatesql-my-friend-2672756</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/updatesql-my-friend-2672756&quot;&gt;&lt;/a&gt;&lt;p&gt;Oh &lt;a href=&quot;http://api.drupal.org/api/function/update_sql/5&quot;&gt;update_sql()&lt;/a&gt;, second most unloved of the drupal database functions (&lt;a href=&quot;http://drupal.org/node/299176&quot;&gt;db_rewrite_sql()&lt;/a&gt; is worse)! If you&#039;ve never used it, it is basically a wrapper for db_query() that you can use in hook_update_N() hooks in a module .install file. You may never need to write one of these hooks unless you maintain a module; or like me you prefer to make database changes via code when I&#039;m pushing some new features out to dev, stage, and live servers.&lt;/p&gt;
&lt;p&gt;The Drupal 6 and 7 versions of the documentation for this function do mention that &quot;%-substitution parameters are not supported.&quot; Definitely also true for the Drupal 5 version I&#039;m still working with. So you can&#039;t do variable substitution like you do with db_query() and most of the time thats not a big deal.&lt;/p&gt;
&lt;p&gt;There is one &lt;b&gt;very&lt;/b&gt; important time though.&lt;/p&gt;
&lt;p&gt;When using db_query(), you call it with a syntax like db_query($sql, $variable1, $variable2); Now, you know about database prefixes, and always sing curly braces around your table names in FROMs and JOINs, and that lets Drupal work on multisite installs very well, or talk to more than one DB at a time. So the $sql part of that function call &lt;b&gt;always&lt;/b&gt; gets passed through a strtr(), or in English, PHP&#039;s string translate function that converts every instace of &#039;{&#039; to the right prefix (generally just deletes it). You have no choice about this, and no way to prevent it from getting every single { and }!&lt;/p&gt;
&lt;p&gt;So far so good, because you only use curly braces around the table names, and that works out just fine, right?&lt;/p&gt;
&lt;p&gt;Now enter update_sql(). This function doesn&#039;t support variable substitution, so your function calls look are just update_sql($sql).&lt;/p&gt;
&lt;p&gt;Like update_sql(&quot;UPDATE {node} SET title = &#039;something else&#039; WHERE nid = 10&quot;); - that is, everything has to be passed as part of a single SQL statement (the $sql part above). The SQL statement that always gets run through strtr() looking for &#039;{&#039; and &#039;}&#039;. Which, if you are trying to update a serialized array, or a block&#039;s visibility code with PHP, or just want to use a { in a node title, it will be deleted. Every time, without exception.&lt;/p&gt;
&lt;p&gt;So if you&#039;re using update_sql() and any part of the data contains a &#039;{&#039; or &#039;}&#039; that you need to keep intact - rewrite it as a db_query() with variable substitution. The strtr() will operate on the $sql part, and the $values get substituted in later and stay intact.&lt;/p&gt;</description>
 <comments>http://drupalhigh.onsugar.com/updatesql-my-friend-2672756#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/SQL">SQL</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drupal5">drupal5</category>
 <category domain="http://drupalhigh.onsugar.com/tag/strtr()">strtr()</category>
 <category domain="http://drupalhigh.onsugar.com/tag/curly braces">curly braces</category>
 <category domain="http://drupalhigh.onsugar.com/tag/escaping">escaping</category>
 <pubDate>Wed, 07 Jan 2009 22:51:53 PST</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/updatesql-my-friend-2672756</guid>
</item>
<item>
 <title>link fields and tokens</title>
 <link>http://drupalhigh.onsugar.com/link-fields-tokens-2672729</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/link-fields-tokens-2672729&quot;&gt;&lt;img  width=160 height=68  src=&#039;http://media2.onsugar.com/files/ons/205/2054838/02_2009/afd951c32ad50771_Picture_4.large.jpg&#039; /&gt;&lt;/a&gt;&lt;p&gt;Did you know the CCK Link field can accept tokens in the link title? I didn&#039;t. Now the link module provides all kinds of ways to format the combination of url + title that get entered, but when asked to have the actual &lt;b&gt;node title&lt;/b&gt; link to the given url - I thought for sure I would have to resort to writing some code, either in template.php or in a tpl file.&lt;/p&gt;
&lt;p&gt;But the Link module and Token module together made it easy. Set the Title to &quot;static title&quot; - this way the user will never be prompted when creating a node, and remember this is the link title, not the node title. Then set it to the token [title-raw] and you&#039;re done! CCK and possibly Views will all work together to get you something like &amp;lt;a href=&quot;[user entered url]&quot;&amp;gt;[node title]&amp;lt;/a&amp;gt;!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;</description>
 <comments>http://drupalhigh.onsugar.com/link-fields-tokens-2672729#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/cck">cck</category>
 <pubDate>Wed, 07 Jan 2009 22:30:13 PST</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/link-fields-tokens-2672729</guid>
</item>
<item>
 <title>How to hook_views_tables_alter()</title>
 <link>http://drupalhigh.onsugar.com/How-hookviewstablesalter-2669697</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/How-hookviewstablesalter-2669697&quot;&gt;&lt;/a&gt;&lt;p&gt;First of all, this only applies to Views1 &amp;amp; Drupal 5 - there&#039;s probably a similar function in views2 however.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The setup&lt;/b&gt;: A timestamp ($node-&amp;gt;created) was being selected in a View. The only options for formatting it are as Short, Long, Medium, Time Ago, or Custom. With custom you can enter any string that can be interpreted by php&#039;s &lt;a href=&quot;http://drupalhigh.onsugar.com/php.net/date&quot;&gt;date()&lt;/a&gt; function, and have that format apply.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The problem&lt;/b&gt;: The site that used a different format as its standard for displaying date and time, let&#039;s say &quot;D F j, Y \a\t g:i A&quot;. We had created a function in template.php called site_format_date() that accepted a timestamp, and returned the date nicely formatted that way. All for reuseability! Now all the dates in the code (and template files, and theme function overrides) we write can call that function. And when Mrs. Editor decides that she really would like it to be something completely different, we can change it in one place and be done!&lt;/p&gt;
&lt;p&gt;&lt;b&gt;The table problem&lt;/b&gt;: What a pain to have to go to each View that uses a time or date, and select the &quot;custom&quot; format, and enter into the textbox the format we want to use. Now when someone wants to change the site-wide format, we&#039;ll have to go back to each view and update all the format fields! Argh!&lt;/p&gt;
&lt;p&gt;So what we&#039;re trying to do, is somehow add our own custom format as one of the options for displaying a timestamp, in addition to the basic ones Drupal and Views provides us. Unfortunately, those choices are created by a call to &lt;a title=&quot;Common Handlers for Views fields&quot; href=&quot;http://drupal.org/node/99565#common-handlers&quot;&gt;views_handler_field_dates()&lt;/a&gt;, which just returns a fixed array of those 5 choices, and there&#039;s no way to get your own in there.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://drupal.org/node/142383&quot;&gt;&lt;b&gt;hook_views_tables_alter()&lt;/b&gt;&lt;/a&gt; to the rescue! This hook lets you modify how the Views module understands the tables in the Drupal database. Most of the core tables are added by .inc files in the views module, and many contrib modules have their own views.inc file. Using this hook you have the opportunity to change anything you like about how views works with modules, and do it safely without hacking any modules.&lt;/p&gt;
&lt;p&gt;The fields I wanted to affect (the created and changed timestamp) are &lt;b&gt;node&lt;/b&gt; fields. You can see them defined in path/to/views/modules/&lt;a href=&quot;http://drupal.org/cvs?file=/modules/views/modules/views_node.inc&quot;&gt;views_node.inc&lt;/a&gt;. I&#039;m trying affect how the &lt;b&gt;fields&lt;/b&gt; are &lt;b&gt;handled&lt;/b&gt; (as opposed to filters, arguments, sorts, or anything else). By checking the .inc file I can see the keys I want to affect are simply called &#039;&lt;b&gt;created&lt;/b&gt;&#039; and &#039;&lt;b&gt;changed&lt;/b&gt;&#039;. Putting that all together, here is my complete hook function :&lt;/p&gt;
&lt;p style=&quot;background-color: #99ccff;&quot;&gt;function hook_views_tables_alter(&amp;amp;$tabledata) {&lt;br /&gt; $tabledata[&#039;node&#039;][&#039;fields&#039;][&#039;created&#039;][&#039;handler&#039;][&#039;my_custom_format_date&#039;] = t(&#039;As My Custom Date&#039;); &lt;br /&gt; $tabledata[&#039;node&#039;][&#039;fields&#039;][&#039;changed&#039;][&#039;handler&#039;][&#039;my_custom_format_date&#039;] = t(&#039;As My Custom Date&#039;); &lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Now when I can choose &quot;As My Custom Date&quot; to format the timestamps! Views will automatically call my_custom_format_date() for me, and I just pass the data right along to our sitewide date formatter.&lt;/p&gt;
&lt;p style=&quot;background-color: #99ccff;&quot;&gt;function my_custom_format_date($fieldinfo, $fielddata, $value, $data) {&lt;br /&gt; return $value ? site_format_date($value) : theme(&#039;views_nodate&#039;);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;If figuring out the syntax of the array to modify was a little confusing (views syntax? confusing? never!) try this little snippet first:&lt;/p&gt;
&lt;p style=&quot;background-color: #99ccff;&quot;&gt;function hook_views_tables_alter(&amp;amp;$tabledata) {&lt;br /&gt; drupal_set_message(print_r($tabledata, TRUE));&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;and you&#039;ll get a very long printout of how every table interacts with the Views module. With some searching and little luck, you should be able to find the section you want to modify. Lots of great &lt;a href=&quot;http://drupal.org/node/109604&quot;&gt;views1 and views2 documentation&lt;/a&gt; is available, but it gets a little hairy! Unfortunately there&#039;s not a lot of documentation that I could find on this very powerful hook! I discovered it while poking through the views.module code and found 1 Drupal issue at &lt;a href=&quot;http://drupal.org/node/142383&quot; title=&quot;http://drupal.org/node/142383&quot;&gt;http://drupal.org/node/142383&lt;/a&gt;. (This was the issue that actually enabled the hook to work properly as of about July 2007).&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Remind me to add some pictures to this post!&lt;/p&gt;</description>
 <comments>http://drupalhigh.onsugar.com/How-hookviewstablesalter-2669697#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/tag/date">date</category>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/tables">tables</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drupal5">drupal5</category>
 <category domain="http://drupalhigh.onsugar.com/tag/views1">views1</category>
 <category domain="http://drupalhigh.onsugar.com/tag/timestamp">timestamp</category>
 <category domain="http://drupalhigh.onsugar.com/tag/format_date">format_date</category>
 <category domain="http://drupalhigh.onsugar.com/tag/views module hooks">views module hooks</category>
 <pubDate>Wed, 07 Jan 2009 00:50:21 PST</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/How-hookviewstablesalter-2669697</guid>
</item>
<item>
 <title>Imagecache and You (err, your picture)</title>
 <link>http://drupalhigh.onsugar.com/Imagecache-You-err-your-picture-2669631</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/Imagecache-You-err-your-picture-2669631&quot;&gt;&lt;/a&gt;&lt;p&gt;When you using imagecache on the $user-&amp;gt;picture, many people have noticed 1 small problem. If someone uploads a new picture, everything appears to work fine, but the user photo stays the same!&lt;/p&gt;
&lt;p&gt;What&#039;s going on? When a user uploads a picture, it gets renamed to a specific filename - doesn&#039;t matter the name of the file you uploaded. Imagecache then makes a copy of that file to display. (Technically this doesn&#039;t happen until the first time the image is viewed with a particular preset). When the new user image is uploaded, it gets the very same name as the previous one, again regardless of the actual filename that was uploaded. Now imagecache will think it already has a cached version of that image, because it just checks the filename and sees that it exists!&lt;/p&gt;
&lt;p&gt;So I was all about to post on how to fix that, basically by linking to &lt;a title=&quot;Lullabots!&quot; href=&quot;http://www.lullabot.com/articles/imagecache_example_user_profile_pictures&quot;&gt;Nate Haug&#039;s excellent post&lt;/a&gt; on how to do just that - but the Imagecache module maintainers have just made &lt;a href=&quot;http://drupal.org/node/354862&quot;&gt;a new release&lt;/a&gt; (for Drupal 5) that includes &lt;a href=&quot;http://drupal.org/node/279861&quot;&gt;a fix for the issue&lt;/a&gt;! So the new solution is - download the latest version of the Imagecache module!&lt;/p&gt;</description>
 <comments>http://drupalhigh.onsugar.com/Imagecache-You-err-your-picture-2669631#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drupal5">drupal5</category>
 <category domain="http://drupalhigh.onsugar.com/tag/imagecache">imagecache</category>
 <category domain="http://drupalhigh.onsugar.com/tag/user picture">user picture</category>
 <category domain="http://drupalhigh.onsugar.com/tag/flush">flush</category>
 <pubDate>Tue, 06 Jan 2009 23:21:42 PST</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/Imagecache-You-err-your-picture-2669631</guid>
</item>
<item>
 <title>Ampersands and CCK</title>
 <link>http://drupalhigh.onsugar.com/Ampersands-CCK-2669617</link>
 <description>&lt;a href=&quot;http://drupalhigh.onsugar.com/Ampersands-CCK-2669617&quot;&gt;&lt;/a&gt;&lt;p&gt;When using a CCK text field that is set to display as a select list, using the &quot;Allowed Values&quot; textarea to specify each of the choices works 99% of the time. But when trying to use an option that included an ampersand, like &quot;Drupal &amp;amp; Drupal&quot;, it keeps getting escaped to &amp;amp;amp; -  stop it CCK!&lt;/p&gt;
&lt;p&gt;What&#039;s going on? Each line of the textarea is eventually passed through &lt;a title=&quot;api.drupal.org : filter_xss()&quot; href=&quot;http://api.drupal.org/api/function/filter_xss/5&quot;&gt;filter_xss()&lt;/a&gt;, which tries it&#039;s best to remove naughty characters like &amp;amp;amp;, becauseof its &lt;a title=&quot;List of XML and HTML character entity references&quot; href=&quot;http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references&quot;&gt;special meaning in HTML&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;How to avoid it? Use the section &quot;PHP Code&quot; and write your values out as an array. &lt;b&gt;You must specify a key and value pair for each option&lt;/b&gt;, CCK will not automatically handle just having the value. Don&#039;t forget to return the array. PHP open and closing tags arent needed. CCK trusts the values found in this block, and pass them through any kind of text filtering, and your ampsersands will sail through undamaged.&lt;/p&gt;
&lt;p&gt;So&lt;/p&gt;
&lt;p style=&quot;background-color: #99ccff;&quot;&gt;Drupal &amp;amp; Drupal&lt;br /&gt; Hans &amp;amp; Franz&lt;br /&gt; Martin &amp;amp; Lewis&lt;/p&gt;
&lt;p&gt;become&lt;/p&gt;
&lt;p style=&quot;background-color: #99ccff;&quot;&gt;return array(&lt;br /&gt;&#039;Drupal &amp;amp; Drupal&#039; =&amp;gt; &#039;Drupal &amp;amp; Drupal&#039;,&lt;br /&gt;&#039;Hans &amp;amp; Franz&#039; =&amp;gt; &#039;Hans &amp;amp; Franz&#039;,&lt;br /&gt;&#039;Martin &amp;amp; Lewis&#039; =&amp;gt; &#039;Martin &amp;amp; Lewis&#039;,&lt;br /&gt;);&lt;/p&gt;</description>
 <comments>http://drupalhigh.onsugar.com/Ampersands-CCK-2669617#comment</comments>
 <category domain="http://drupalhigh.onsugar.com/category/drupal">drupal</category>
 <category domain="http://drupalhigh.onsugar.com/tag/drupal5">drupal5</category>
 <category domain="http://drupalhigh.onsugar.com/tag/filtering">filtering</category>
 <category domain="http://drupalhigh.onsugar.com/tag/xss">xss</category>
 <pubDate>Tue, 06 Jan 2009 22:58:15 PST</pubDate>
 <dc:creator>krs</dc:creator>
 <guid>http://drupalhigh.onsugar.com/Ampersands-CCK-2669617</guid>
</item>
</channel>
</rss>

