<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5613421439231161057</id><updated>2012-02-16T10:21:08.028-05:00</updated><category term='PHP'/><category term='Views'/><category term='phpMyAdmin'/><category term='MySQL'/><category term='Content Type'/><category term='Drupal 6'/><category term='CCK'/><category term='Pathauto'/><category term='Sharepoint'/><category term='Contemplate'/><title type='text'>weekbeforenext</title><subtitle type='html'>problem solving skillz</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5613421439231161057.post-4064312777034994377</id><published>2011-07-18T16:14:00.000-04:00</published><updated>2011-07-18T16:14:38.961-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint'/><title type='text'>No Left Navigation on New Web Part Pages</title><content type='html'>I found it a bit frustrating to manually add the left navigation to every new web parts page created in Sharepoint 2010. The manual process includes commenting out two chunks of code in each web parts page created which I figured out with the help of this site:&amp;nbsp;&lt;a href="http://blogs.technet.com/b/seanearp/archive/2011/03/09/how-to-create-a-sharepoint-2010-web-part-page-that-inherits-the-site-s-left-navigation.aspx"&gt;http://blogs.technet.com/b/seanearp/archive/2011/03/09/how-to-create-a-sharepoint-2010-web-part-page-that-inherits-the-site-s-left-navigation.aspx&lt;/a&gt;. I knew there had to be a way to do it once for all new web parts pages.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;ol&gt;&lt;li&gt;Connect to your Sharepoint 2010 server.&lt;/li&gt;&lt;li&gt;Navigate to:&amp;nbsp;Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\1033\STS\DOCTEMP\SMARTPGS&lt;/li&gt;&lt;li&gt;Open your site in Microsoft Sharepoint Designer.&lt;/li&gt;&lt;li&gt;Open each of the eight spstd?.aspx files in Microsoft Sharepoint Designer.&lt;/li&gt;&lt;li&gt;Comment out the following lines using "&amp;lt;%--" at the beginning and "--%&gt;" at the end:&lt;br/&gt;&lt;br /&gt;(at approximately line 32)&lt;br /&gt;&lt;pre&gt;&amp;lt;style type="text/css"&gt;&lt;br /&gt;body #s4-leftpanel {&lt;br /&gt; display:none;&lt;br /&gt;}&lt;br /&gt;.s4-ca {&lt;br /&gt; margin-left:0px;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/style&gt;&lt;br /&gt;&lt;/pre&gt;and (at approximately line 56)&lt;br /&gt;&lt;pre&gt;&amp;lt;asp:content contentplaceholderid="PlaceHolderNavSpacer" runat="server"&gt;&amp;lt;/asp:content&gt;&lt;br /&gt;&amp;lt;asp:content contentplaceholderid="PlaceHolderLeftNavBar" runat="server"&gt;&amp;lt;/asp:content&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Save each spstd?.aspx file. &lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Now the left navigation will be visible by default on all new web parts pages, but still give you the ability to manually hide it by removing the comment from specific files.&lt;/div&gt;&lt;div&gt;This site helped a lot in setting this up: &lt;a href="http://patrickboom.wordpress.com/2010/04/16/how-to-add-the-quick-launch-to-the-default-web-part-page-templates/"&gt;http://patrickboom.wordpress.com/2010/04/16/how-to-add-the-quick-launch-to-the-default-web-part-page-templates/&lt;/a&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613421439231161057-4064312777034994377?l=weekbeforenext-blog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/4064312777034994377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/07/no-left-navigation-on-new-web-part.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/4064312777034994377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/4064312777034994377'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/07/no-left-navigation-on-new-web-part.html' title='No Left Navigation on New Web Part Pages'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613421439231161057.post-4083122797296728200</id><published>2011-07-08T09:29:00.002-04:00</published><updated>2011-07-08T09:30:58.676-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='phpMyAdmin'/><category scheme='http://www.blogger.com/atom/ns#' term='Drupal 6'/><title type='text'>Access Denied for All Users</title><content type='html'>I recently encountered a problem logging in. I could log in as the admin or any other user, but it would show the "Access Denied" message instead of the admin controls. The site worked fine for anonymous users, but no one could log in to make changes.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;I have found that when there are server issues, such as a power failure, and the Drupal site is not functioning properly when it is back up, the first place to check is the MySQL database. You can quickly identify tables that are in need of repair by looking for tables that display "in use" instead of the table information.&lt;br /&gt;&lt;br /&gt;I used phpMyAdmin to take a look at the database. Viewing the database structure, the accesslog and sessions tables were "in use" and in need of repair. I clicked on the SQL tab and ran two different SQL commands:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;repair table accesslog;&lt;/li&gt;&lt;li&gt;repair table sessions;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Once both tables were successfully repaired, users were able to log in to the site again.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613421439231161057-4083122797296728200?l=weekbeforenext-blog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/4083122797296728200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/07/access-denied-for-all-users.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/4083122797296728200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/4083122797296728200'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/07/access-denied-for-all-users.html' title='Access Denied for All Users'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613421439231161057.post-757996409130636508</id><published>2011-06-29T11:41:00.003-04:00</published><updated>2011-06-29T14:01:45.824-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint'/><title type='text'>Extracting Month and Year from a Date and Time Field</title><content type='html'>I created a series of of document libraries in Sharepoint 2010 to archive minutes from meetings. I wanted to create a view that grouped the minutes by year and month, but I only wanted users to enter the date of the meeting. I figured out how to extract the month and year from the date column and display those as separate columns.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;After creating a new document library, I created a Date and Time column named Date.&lt;br /&gt;&lt;br /&gt;Then I created a Calculated (calculation based on other columns) column named Month. Since I didn't want the months displayed in alphabetical order, I also pulled the numeric value of the month.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Month formula:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;=TEXT([Date],"mm")&amp;amp;" "&amp;amp;TEXT([Date],"mmmm")&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Formula output:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;05 May&lt;br /&gt;&lt;br /&gt;Finally, I created a Calculated (calculation based on other columns) column named Year.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Year formula:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;=TEXT([Date],"yyyy")&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Formula output:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;2011&lt;br /&gt;&lt;br /&gt;Now that I had year and month columns, I created a view that grouped by Year (descending) then Month (decending).&lt;br /&gt;&lt;br /&gt;This site helped me get started:&amp;nbsp;&lt;a href="http://www.sharepointboris.net/2009/05/get-the-month-name-in-calculated-column/"&gt;http://www.sharepointboris.net/2009/05/get-the-month-name-in-calculated-column/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613421439231161057-757996409130636508?l=weekbeforenext-blog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/757996409130636508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/06/extracting-month-and-year-from-date-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/757996409130636508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/757996409130636508'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/06/extracting-month-and-year-from-date-and.html' title='Extracting Month and Year from a Date and Time Field'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613421439231161057.post-4763825218908869002</id><published>2011-05-13T23:31:00.012-04:00</published><updated>2011-06-14T16:37:15.358-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Content Type'/><category scheme='http://www.blogger.com/atom/ns#' term='Contemplate'/><category scheme='http://www.blogger.com/atom/ns#' term='Drupal 6'/><category scheme='http://www.blogger.com/atom/ns#' term='CCK'/><title type='text'>Redirection that works</title><content type='html'>Content administrators needed a way to control the URL to their external web application and be able to edit/show a maintenance message when the application was down for updates.&lt;br /&gt;&lt;br /&gt;I created a new content type with a CCK link field for the URL and a single on/off check box for the administrator to turn the maintenance message on or off. The maintenance message lived in the default title and body.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;I affected body output in the template for the new content type to send the user to the URL if the checkbox is not checked and show the maintenance message if it is checked. &lt;br /&gt;&lt;br /&gt;My initial code looked like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//if the check box is not checked...&lt;br /&gt;if($node-&gt;field_CHECKBOX[0]['value'] != 'on'){&lt;br /&gt;&lt;br /&gt;//redirect the user to the URL&lt;br /&gt;header('Location:'$node-&gt;field_URL[0]['url']);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//show the maintenance message if the user wasn't redirected.&lt;br /&gt;print $node-&gt;content['body']['#value']; &lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;My first problem was that if I created a node of this type and left the box unchecked for the redirection to occur, I couldn't edit the template. I added to the if statement that the URI couldn't start with '/admin' so it wouldn't redirect if I was on an admin page. At the same time, I decided to also make sure the node was published.&lt;br /&gt;&lt;br /&gt;Here's what the code looked like after changes:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//if the check box is not checked, the URI doesn't start with '/admin' and the node is published...&lt;br /&gt;if($node-&gt;field_CHECKBOX[0]['value'] != 'on'  &amp;&amp; substr($_SERVER["REQUEST_URI"], 0, 6) != '/admin' &amp;&amp; $node-&gt;status == 1){&lt;br /&gt;&lt;br /&gt;//redirect the user to the URL&lt;br /&gt;header('Location:'$node-&gt;field_URL[0]['url']);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//show the maintenance message if the user wasn't redirected.&lt;br /&gt;print $node-&gt;content['body']['#value']; &lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This code worked fine while I was logged in, but when I tested as an anonymous user, it worked on the first click and stopped redirecting afterwards. Flushing the cache or refreshing the page didn't fix the problem. &lt;br /&gt;&lt;br /&gt;Through some testing, I discovered that it was the header() function that was the problem. I think it worked inconsistently because that function is suppose to be used on the first line of a page. &lt;br /&gt;&lt;br /&gt;In searching for a different way to redirect in Drupal, I found the function &lt;a href="http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_goto/6"&gt;drupal_goto()&lt;/a&gt;. This worked every time the page was accessed.&lt;br /&gt;&lt;br /&gt;Here is the final code:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//if the check box is not checked, the URI doesn't start with '/admin' and the node is published...&lt;br /&gt;if($node-&gt;field_CHECKBOX[0]['value'] != 'on' &amp;&amp; substr($_SERVER["REQUEST_URI"], 0, 6) != '/admin' &amp;&amp; $node-&gt;status == 1){&lt;br /&gt;&lt;br /&gt;//redirect the user to the URL using &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.8"&gt;HTTP response code 307&lt;/a&gt;&lt;br /&gt;drupal_goto($path = $node-&gt;field_URL[0]['url'], $query = NULL, $fragment = NULL, $http_response_code = 307);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//show the maintenance message if the user wasn't redirected.&lt;br /&gt;print $node-&gt;content['body']['#value']; &lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;In conclusion, drupal_goto() works best for redirecting within the content of a node.&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613421439231161057-4763825218908869002?l=weekbeforenext-blog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/4763825218908869002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/05/redirection-that-works.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/4763825218908869002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/4763825218908869002'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/05/redirection-that-works.html' title='Redirection that works'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613421439231161057.post-5723984015543431710</id><published>2011-05-11T16:12:00.000-04:00</published><updated>2011-05-13T23:58:29.485-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='phpMyAdmin'/><category scheme='http://www.blogger.com/atom/ns#' term='Drupal 6'/><title type='text'>MySQL crashed and nodes display "n/a"</title><content type='html'>MySQL crashed due to a lack of hard drive space. More hard drive space was allocated and MySQL was restarted. For a moment, the site appeared to be fine. A minute later, everywhere a node was suppose to display, "n/a" appeared instead.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;I reviewed the MySQL database using phpMyAdmin to see if I could find node content. When I viewed the node_revisions table, an error message displayed that indicated that the table needed to be repaired.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note: A better way to find tables that need repair is to view the structure of the entire database. A table that needs repair doesn't display records, type, collation, etc. It will display "in use" instead.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Usually in a table view, a Repair table link is available under the Operations tab, but in this case it wasn't available. I used the MySQL Client to run the the repair table command: repair table node_revisions;*&lt;br /&gt;&lt;br /&gt;That did the trick. The node content displayed and the site was back up - crisis managed.&lt;br /&gt;&lt;br /&gt;One other problem occurred regarding one particular node. The node showed in the Content list, but you couldn't view or edit the node and it threw a 404 error. When I check the database, the node existed in the node table and node content existed in the node_revisions table.&lt;br /&gt;&lt;br /&gt;The problem was that in the node table, the vid (version id) for that node was 0 instead of the vid of the last revision in node_revisions. I searched for the nid (node id) in the node_revisions table. I sorted the results by vid and copied the last vid number. I searched for the nid in the node table and replaced the vid with the number I copied.&lt;br /&gt;&lt;br /&gt;The node was accessible again and the content was back.&lt;br /&gt;&lt;br /&gt;So, if this happens to you:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;b&gt;Review your database structure in phpMyAdmin and look for tables that show "in use."&lt;/b&gt; Use the MySQL command: repair table tablename; in the MySQL command line.*&lt;/li&gt;&lt;li&gt;&lt;b&gt;Search the node table for vid = 0.&lt;/b&gt;&amp;nbsp;For each node that has a vid of 0, search for the nid in the node_revisions table and copy and replace the vid in the node table.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;i&gt;*Before you can use the REPAIR TABLE MySQL command, you have to &lt;/i&gt;&lt;a href="http://www.bios.niu.edu/johns/bioinform/mysql_commands.htm"&gt;&lt;i&gt;use the database&lt;/i&gt;&lt;/a&gt;&lt;i&gt;.&amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613421439231161057-5723984015543431710?l=weekbeforenext-blog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/5723984015543431710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/05/mysql-crashed-and-nodes-display-na.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/5723984015543431710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/5723984015543431710'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/05/mysql-crashed-and-nodes-display-na.html' title='MySQL crashed and nodes display &quot;n/a&quot;'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613421439231161057.post-6549353966330893763</id><published>2011-05-09T15:03:00.002-04:00</published><updated>2011-05-09T15:06:47.940-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Drupal 6'/><category scheme='http://www.blogger.com/atom/ns#' term='Pathauto'/><title type='text'>Pathauto Bug: "Array" in the URL alias</title><content type='html'>I discovered a bug using Pathauto 6.x-1.5. When I would save a Page node with the URL path settings set to Automatic alias, the URL alias would insert "Array" instead of the token I assigned. When I reverted back to Pathauto 6.x - 1.4, the problem disappeared.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://drupal.org/node/1141402"&gt;http://drupal.org/node/1141402&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613421439231161057-6549353966330893763?l=weekbeforenext-blog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/6549353966330893763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/05/pathauto-bug-array-in-url-alias.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/6549353966330893763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/6549353966330893763'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/05/pathauto-bug-array-in-url-alias.html' title='Pathauto Bug: &quot;Array&quot; in the URL alias'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5613421439231161057.post-8106024033806977294</id><published>2011-04-15T11:47:00.009-04:00</published><updated>2011-06-14T16:17:24.687-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Views'/><category scheme='http://www.blogger.com/atom/ns#' term='Drupal 6'/><title type='text'>Turn a select into an autocomplete textfield in a Views exposed form</title><content type='html'>Within a Views exposed filter form, there was a select for a node reference field. The client wanted the select to be a textfield because it only required 3 characters and it would be faster for users to type them than find them in a select. I decided it would be even cooler to make it an autocomplete textfield.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;I used &lt;a href="http://drupal.org/node/179922#comment-1467932"&gt;http://drupal.org/node/179922#comment-1467932&lt;/a&gt;&amp;nbsp;as a starting point and made modifications.&lt;br /&gt;&lt;br /&gt;Here's my .module code for Drupal 6.x:&lt;br /&gt;&lt;pre&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;// $Id: MODULE_NAME.module&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;*@file&lt;br /&gt;* Module Name&lt;br /&gt;* Turns a select into an autocomplete textfield.&lt;br /&gt;*&lt;br /&gt;* Specific for 'NODE_NAME' nodes and the 'VIEW_NAME' view&lt;br /&gt;*&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Implementation of hook_menu().&lt;br /&gt;*/&lt;br /&gt;function MODULE_NAME_menu(){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;//Initialize the $items array.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$items = array();&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;//Add menu for the node autocomplete textfield's #autocomplete_path.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$items['NODE_NAME/autocomplete'] = array(&lt;br /&gt;//Required. The untranslated title of the menu item.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'title' =&amp;gt; t('Node Title'),&lt;br /&gt;//The function to call to display a web page when the user visits the path. If omitted, the parent menu item's callback will be used instead.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'page callback' =&amp;gt; 'NODE_NAME_autocomplete',&lt;br /&gt;//An array of arguments to pass to the access callback function. Integer values pass the corresponding URL component.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'access arguments' =&amp;gt; array('access content'),&lt;br /&gt;//Callbacks simply register a path so that the correct function is fired when the URL is accessed.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'type' =&amp;gt; MENU_CALLBACK&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;);&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;//Return the $items array with the new menu item.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return $items;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Implementation of hook_form_alter().&lt;br /&gt;*/&lt;br /&gt;function MODULE_NAME_form_alter(&amp;amp;$form, $form_state, $form_id){&lt;br /&gt;&lt;br /&gt;//Only affect a views exposed form.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if($form_id == 'views_exposed_form'){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;//If a view exists, retreive form_state information.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (array_key_exists('view', $form_state)){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&lt;br /&gt;//If the view has a name,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (array_key_exists('name', $form_state['view'])){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;&lt;br /&gt;//Only affect the specified view.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ($form_state['view']-&amp;gt;name == 'VIEW_NAME'){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;&lt;br /&gt;//Turn the node select into a textfield.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$form['SELECT_FIELD']['#type'] ='textfield';&lt;br /&gt;//Turns the node textfield into an autocomplete textfield.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$form['SELECT_FIELD']['#autocomplete_path'] ='NODE_NAME/autocomplete';&lt;br /&gt;//Remove options from the node autocomplete textfield so errors aren't thrown if the user enters something that doesn't exist.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;unset($form['SELECT_FIELD']['#options']);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Autocomplete Function for nodes.&lt;br /&gt;*/&lt;br /&gt;function NODE_NAME_autocomplete($string = ''){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;//Initialize the $matches array.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$matches = array();&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;//Ensure that a string has been passed.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if ($string){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;//Remove any extra spaces before or after the meaningful string.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$string = trim($string);&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;//Set the query to select all nodes that are published and match what the user entered. - use '%%%s%%' to match from anywhere in the title&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$query = "SELECT title FROM {node} WHERE type='NODE_NAME' and title like '%s%'";&lt;br /&gt;//Run the query and restrict the results to the first 10.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$result = db_query_range($query,$string,0,10);&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;//Ensure there are results returned from the query.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;if ($result != false){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&lt;br /&gt;//Loop through the all of the results.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;while ($NODE_NAME = db_fetch_object($result)){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;&lt;br /&gt;//Add the plain text select field to the $matches array with the $key set as the same.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;$matches[$NODE_NAME-&amp;gt;title] = check_plain($NODE_NAME-&amp;gt;title);&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;//Converts the $matches array into its Javascript equivalent and prints it to the page output.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;print drupal_to_js($matches);&lt;br /&gt;//Exit the function.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;exit;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Implementation of hook_views_query_alter().&lt;br /&gt;*/&lt;br /&gt;function MODULE_NAME_views_query_alter(&amp;amp;$view, &amp;amp;$query){&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;//Ensure that the WHERE information exists as an array in the query which is not empty.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (is_array($query-&amp;gt;where) &amp;amp;&amp;amp; !empty($query-&amp;gt;where)){&lt;br /&gt;&lt;br /&gt;//Search the where clauses for the select field clause.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;$index_value = array_search("node_data_SELECT_FIELD.SELECT_FIELD = '%s'", $query-&amp;gt;where[0][clauses]);&lt;br /&gt;&lt;br /&gt;//If the select field clause was found,&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;if ($index_value != '' &amp;amp;&amp;amp; $index_value != false){&lt;br /&gt;&lt;br /&gt;//If the cooresponding argument is not blank or all,&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;if($query-&amp;gt;where[0][args][$index_value] == '' || strtolower($NODE_NAME_title) == "all"){&lt;br /&gt;&lt;br /&gt;//remove the clause and argument because the user isn't searching by the select field.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;unset($query-&amp;gt;where[0][clauses][$index_value]);&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;unset($query-&amp;gt;where[0][args][$index_value]);&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;else{&lt;br /&gt;//Get the argument that cooresponds to the select field where clause.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;$NODE_NAME_title = strtoupper($query-&amp;gt;where[0][args][$index_value]);&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;&lt;br /&gt;//Select the node id of the select field argument.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;$NODE_NAME_nid = db_result(db_query("SELECT nid FROM {node} WHERE title = '%s'",$NODE_NAME_title));&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;&lt;br /&gt;//If a node id was found for the select field argument,&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;if($NODE_NAME_nid){&lt;br /&gt;&lt;br /&gt;//replace the select field with the cooresponding node id in the argument.&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;$query-&amp;gt;where[0][args][$index_value] = $NODE_NAME_nid;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;else{&lt;br /&gt;//If the node id wasn't found, replace the select field with 0 as a nonexistent node id that will not return results.&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;$query-&amp;gt;where[0][args][$index_value] = 0;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5613421439231161057-8106024033806977294?l=weekbeforenext-blog.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://weekbeforenext-blog.blogspot.com/feeds/8106024033806977294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/04/turn-select-into-autocomplete-textfield.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/8106024033806977294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5613421439231161057/posts/default/8106024033806977294'/><link rel='alternate' type='text/html' href='http://weekbeforenext-blog.blogspot.com/2011/04/turn-select-into-autocomplete-textfield.html' title='Turn a select into an autocomplete textfield in a Views exposed form'/><author><name>April</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
