<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://befused.com" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
 <title>Drupal Posts | be fused</title>
 <link>http://befused.com/drupal-feed</link>
 <description></description>
 <language>en</language>
<item>
 <title>Review of Drush User’s Guide book</title>
 <link>http://befused.com/drupal/drush-users-guide</link>
 <description>&lt;p&gt;&lt;a href=&quot;http://link.packtpub.com/1gVxbE&quot;&gt;&lt;img src=&quot;/files/DrushUsersGuide_cover.jpg&quot; align=&quot;right&quot; alt=&quot;Drush User&#039;s Guide cover&quot; width=&quot;125&quot; height=&quot;151&quot; /&gt;&lt;/a&gt;The Drush User’s Guide, by &lt;a href=&quot;http://drupal.org/user/682736&quot;&gt;Juan Pablo Novillo Requena&lt;/a&gt;, is a fairly short technical book, at just over 120 pages. Like meetings, the shorter the better for technical books. It is easy to read, concise and well laid out. If you are new to Drupal, this book is not for you. If you build sites in Drupal but are new to Drupal development (module development), then you will find this really useful. If you are a Drupal developer who writes custom Drupal modules, you will find this book essential reading. I have used Drush for a few years and still picked up a thing or two. &lt;!--break--&gt;&lt;/p&gt;
&lt;p&gt;It covers all the usual commands that, if you have used Drush for any length of time, you might already use. But it covers a whole lot more and I am sure there will be new tricks in it for all but the most hard core Drush users. &lt;/p&gt;
&lt;p&gt;There is a great walk through of Devel’s Drush commands. For example, you can search for implementations of a single hook and then view the source code of that implementation. Also useful for adding test nodes and users. &lt;/p&gt;
&lt;p&gt;I use Features a lot and the Drush User’s Guide includes everything there is know about creating, updating and managing Features through Drush. &lt;/p&gt;
&lt;p&gt;I particularly liked the section on site aliases. This will be a real time saver for many people, if you are running multiple Drupal sites or a dev pipeline (dev, stage, live). &lt;/p&gt;
&lt;h2&gt;What is in the book?&lt;/h2&gt;
&lt;h3&gt;Chapter 1: Installation and basic usage&lt;/h3&gt;
&lt;p&gt;The usual stuff about installation. &lt;/p&gt;
&lt;h3&gt;Chapter 2: Executing Drush Commands&lt;/h3&gt;
&lt;p&gt;The core Drush commands, such as installing Drupal core, modules, creating users and roles, running cron. Some good stuff that might be new to some people like running SQL commands with Drush,  backing up,  restoring and syncing website files and databases. &lt;/p&gt;
&lt;h3&gt;Chapter 3: Customising Drush&lt;/h3&gt;
&lt;p&gt;How to create custom Drush commands, altering existing commands, running PHP scripts (with or without Drupal bootstrap), site aliases.  &lt;/p&gt;
&lt;h3&gt;Chapter 4: Extending Drush&lt;/h3&gt;
&lt;p&gt;Using Drush commands from modules such as Backup and Migrate, Devel, Features, Views, Module Builder. Also creating a Drupal installation with pre packaged set of modules using Drush Make. &lt;/p&gt;
&lt;h2&gt;What is missing?&lt;/h2&gt;
&lt;p&gt;There is no mention of adding your own Drush commands to module you create. There is a great section on adding custom commands but the focus was on adding custom commands that can be used on any Drupal install on your system. But if you are writing your own custom or contrib modules, you will probably want to add Drush commands to that module. &lt;/p&gt;
&lt;h2&gt;The good and the bad summary&lt;/h2&gt;
&lt;h3&gt;Good&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Good chapter layout&lt;/li&gt;
&lt;li&gt;Good pace and easy to read&lt;/li&gt;
&lt;li&gt;Excellent examples&lt;/li&gt;
&lt;li&gt;Didn’t bore with site building tutorials (like setting up views)&lt;/li&gt;
&lt;li&gt;Good reference book and can be read cover to cover&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Bad&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;A few (minor) grammatical errors&lt;/li&gt;
&lt;li&gt;No discussion of how to add Drush commands to a new module&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The Drush User’s Guide is a must have for any serious Drupal developer or site builder. If will serve as a handy resource and at the same time is easy book to read cover to cover. It will teach you how to use Drush properly and to use Drush properly, is to save a lot of time.&lt;/p&gt;
&lt;h2&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;I volunteered to review this book and received a free copy from Packt Publishing. &lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/drush-users-guide#comments</comments>
 <category domain="http://befused.com/drupal">Drupal</category>
 <category domain="http://befused.com/drupal/module-development">Drupal Module Development</category>
 <pubDate>Wed, 06 Jun 2012 14:53:24 +0100</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">253 at http://befused.com</guid>
</item>
<item>
 <title>How to contribute a patch to drupal.org</title>
 <link>http://befused.com/drupal/contribute-patch</link>
 <description>&lt;p&gt;Lets say you have found a bug in someone else&#039;s contributed module. It happens! You could raise an issue in the issue queue for that module, or you could fix it yourself and contribute the fix back to the community. You are not always going to be able to fix it yourself, but if you can, you should, as this will help everyone, not just the module maintainer. &lt;!--break--&gt;&lt;/p&gt;
&lt;h2&gt;Raise an issue&lt;/h2&gt;
&lt;p&gt;Create an issue on drupal.org. You will need the issue number, which is the node ID of the issue.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/files/node_id_issue_id.jpg&quot; alt=&quot;The issue ID is the node ID&quot; width=&quot;590&quot; height=&quot;173&quot; /&gt;&lt;/p&gt;
&lt;p&gt;If you are attaching the patch to a comment on the issue, you will also need the comment ID. &lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/files/issue_comment_id.jpg&quot; alt=&quot;The comment ID on an issue&quot; width=&quot;589&quot; height=&quot;156&quot;/&gt;&lt;/p&gt;
&lt;h2&gt;Create the patch file&lt;/h2&gt;
&lt;p&gt;There are two main ways that you can use to create the patch file. The easiest and most straight forward is if you have the module under source control, like Git or SVN, as follows. &lt;/p&gt;
&lt;h3&gt;Git or SVN&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Make the changes to the module&lt;/li&gt;
&lt;li&gt;Run git status and you will see the module file has changed.&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;git status&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Create the patch with this command:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;git diff &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;description&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;issue&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;number&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;comment&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;number&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;patch &lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can do the same thing with SVN.&lt;/p&gt;
&lt;h3&gt;Diff command&lt;/h3&gt;
&lt;p&gt;If you do not have the file under version control, you can use the diff command to create the patch file. &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Make the changes to the module&lt;/li&gt;
&lt;li&gt;Save with a different file name, so you have the original file and new file&lt;/li&gt;
&lt;li&gt;Create the patch with this command:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;diff original&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;module &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;module &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;description&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;issue&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;number&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;comment&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;number&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;patch &lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Contribute back&lt;/h2&gt;
&lt;p&gt;Make a comment on the issue and attach the patch file. Change the status to &quot;needs review&quot;. Now the module maintainer is not only aware of the bug, but also has been given a solution. Even if your solution is not perfect, it is still a great help. &lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/contribute-patch#comments</comments>
 <category domain="http://befused.com/drupal">Drupal</category>
 <category domain="http://befused.com/drupal/module-development">Drupal Module Development</category>
 <pubDate>Tue, 31 Jan 2012 14:05:13 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">249 at http://befused.com</guid>
</item>
<item>
 <title>Hierarchical Select Pathauto termpath breaks with multiple vocabulary</title>
 <link>http://befused.com/drupal/hierarchical-select-pathauto-termpath-breaks-multiple-vocabulary</link>
 <description>&lt;p&gt;The codebase I am working on uses hierarchical select with taxonomy to make it easy for editors to tag from nested terms. Pathauto is used to create the URL alias for the content type. We need both the parent and child terms in the URL, so use this token: [save-lineage-termpath-raw].&lt;/p&gt;
&lt;p&gt;However, a problem occurs when you add a second vocabulary for the same content type. This breaks pathauto and it can not create the URL alias. Fortunately there is another token to save the day: [save-lineage-termpath-raw:vid]. &lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;[save-lineage-termpath-raw:vid]. only has output when terms are present for the vocabulary with the specified vid.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In this case, the vocabulary that I want to use with this path is the first one, which has an ID of 1. So the token is: [save-lineage-termpath-raw:1]&lt;/p&gt;
&lt;p&gt;At this point, alarm bells start ringing because when you save the pathauto form, you will get a validation error. &lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The Pattern for all Car review paths is using the following invalid tokens: [save-lineage-termpath-raw:1].&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Fortunately there is a patch for this already, which you can find here: &lt;a href=&quot;http://drupal.org/node/1137056&quot;&gt;http://drupal.org/node/1137056&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t know how to apply a patch, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Save the patch file to your machine (in this case:  /Users/blair/Sites/Drupal/patches)&lt;/li&gt;
&lt;li&gt;In terminal, navigate to the root of the hierarchical_select module folder (sites/all/hierarchical_select)&lt;/li&gt;
&lt;li&gt;Run the following command: patch -p0 -i /Users/blair/Sites/Drupal/patches/hs_taxonomy-token-list.patch&lt;/li&gt;
&lt;/ol&gt;
</description>
 <comments>http://befused.com/drupal/hierarchical-select-pathauto-termpath-breaks-multiple-vocabulary#comments</comments>
 <category domain="http://befused.com/drupal/troubleshooting">Drupal Troubleshooting</category>
 <category domain="http://befused.com/drupal/hierarchical-select">Hierarchical Select</category>
 <category domain="http://befused.com/drupal/pathauto">pathauto</category>
 <pubDate>Tue, 10 Jan 2012 14:57:07 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">246 at http://befused.com</guid>
</item>
<item>
 <title>Upgrading BeFused from Drupal 5 to 7</title>
 <link>http://befused.com/drupal/upgrade-5to7</link>
 <description>&lt;p&gt;I have a confession to make. This site runs on Drupal 5! Back in its day, Drupal 5 was a great system. But it a far cry from what Drupal 7 now offers. I have plenty of experience upgrading sites from Drupal 5 to Drupal 6, but I want to take this all the way to Drupal 7.&lt;br /&gt;
&lt;!--break--&gt;&lt;/p&gt;
&lt;h2&gt;Upgrade options&lt;/h2&gt;
&lt;p&gt;I have 2 main options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Follow the upgrade path&lt;/li&gt;
&lt;li&gt;Rebuild in Drupal 7 and migrate the data&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If it were a Drupal 5 to 6, or Drupal 6 to 7 upgrade, I could normally recommend the first option. This is especially true if you want the site design and features to be status quo. &lt;/p&gt;
&lt;p&gt;However, in this case, I want to rebuild the site anyway, because I built this site around 5 years ago and have made mistakes that I won&#039;t repeat. This is a good opportunity to start afresh. Also, a Drupal 5 to 7 upgrade would involve 2 upgrades - 5 to 6 and then 6 to 7. It is not a very complicated site (mainly just a blog), so the data migration should be fairly straight forward. &lt;/p&gt;
&lt;p&gt;So for this one, I am going to take the second option and rebuild and migrate. &lt;/p&gt;
&lt;h2&gt;Migrating the data&lt;/h2&gt;
&lt;p&gt;I have a few options for migrating the data.&lt;/p&gt;
&lt;h3&gt;Migration module&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;http://drupal.org/project/migrate&quot;&gt;Migrate&lt;/a&gt; module is designed to migrate data from other sources into Drupal. For example, migrating from another CMS to Drupal. However, it should be very useful for a Drupal to Drupal migration as well.&lt;/p&gt;
&lt;h3&gt;Node Import&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://drupal.org/project/node_import&quot;&gt;Node Import&lt;/a&gt; will import content from a CSV file and you can map to content type fields, taxonomy and users. So I could export content from this site as CSV and then use Node Import to import to the Drupal 7 site.&lt;/p&gt;
&lt;h3&gt;Feeds&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;http://drupal.org/project/feeds&quot;&gt;Feeds&lt;/a&gt; module imports content from a feed (RSS, Atom etc) and creates nodes, users and taxonomy terms. It also supports CSV, so has some overlap with Node Import. It is aimed more at aggregating content from other sites/sources on a regular basis, but can equally be used for a one off migration. &lt;/p&gt;
&lt;h3&gt;Script it&lt;/h3&gt;
&lt;p&gt;I could write a PHP script, or Drupal module, to grab the content from the Drupal 5 database, and then connect to the Drupal 7 database and insert it. If it were a Drupal 6 to 7 migration, I could use the &lt;a href=&quot;http://api.drupal.org/api/drupal/includes--form.inc/group/batch/6&quot;&gt;Batch API&lt;/a&gt; to prevent PHP timeouts. However, the Batch API is not available in Drupal 5. &lt;/p&gt;
&lt;h2&gt;Stay tuned&lt;/h2&gt;
&lt;p&gt;Once the rebuild and migration is complete, I will write another post to outline the migration approach that I took and a tutorial on how to do it.&lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/upgrade-5to7#comments</comments>
 <category domain="http://befused.com/drupal">Drupal</category>
 <category domain="http://befused.com/ideas">Ideas</category>
 <pubDate>Sat, 03 Dec 2011 10:15:28 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">244 at http://befused.com</guid>
</item>
<item>
 <title>DrupalCon London 2011</title>
 <link>http://befused.com/drupal/drupalcon-london-2011</link>
 <description>&lt;p&gt;&lt;img style=&quot;width: 300px; height: 89px&quot; src=&quot;/files/u1/drupalcon_london_1.png&quot; alt=&quot;Drupalcon London logo&quot; title=&quot;Drupalcon London logo&quot; width=&quot;300&quot; height=&quot;89&quot; align=&quot;right&quot; /&gt;I was fortunate enough to be part of the biggest DrupalCon so far, DrupalCon London. 1,751 Drupalistas were there, attending a total of 73 sessions, participating in code sprints, making friends and having a good time.&lt;/p&gt;
&lt;p&gt;&lt;!--break--&gt;
&lt;p&gt;This was my first DrupalCon and it did not disappoint. There were some great sessions by very talented presenters and I thoroughly enjoyed them. The best aspect of DrupalCon for me was the real sense of community. Drupal is, after all, as much about the community as it is about the technology.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/drupalassoc/6072349311/&quot; title=&quot;DrupalCon London Group Photo - Drupal Association&quot;&gt;&lt;img src=&quot;http://farm7.static.flickr.com/6089/6072349311_ea235c2352.jpg&quot; alt=&quot;DrupalCon London Group Photo&quot; width=&quot;500&quot; height=&quot;256&quot; /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Group photo of the Drupalistas&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;My Session Highlights&lt;/h2&gt;
&lt;h3&gt;Designing the Sustainable Web&lt;/h3&gt;
&lt;p&gt; The biggest highlight for me was the keynote on Thursday: Designing the Sustainable Web, by The Web Standardistas. It was a relaxed and amusing performance by Christopher Murphy and Nicklas Persson. They took us through the history of design and how design principles from early 20th Century are relevant to web design today. Particular emphasis was put on grid system and they showed us some great examples of grid implementations.   &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://london2011.drupal.org/scheduleitem/keynote-designing-sustainable-web&quot;&gt;See video&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;State of Drupal 2011&lt;/h3&gt;
&lt;p&gt; The first keynote was by &lt;a href=&quot;http://buytaert.net&quot;&gt;Dries Buytaert&lt;/a&gt;, Drupal&amp;#39;s founder and project lead. He took us through the findings of the State of Drupal survey, which contains some very interesting stats. One important trend is that a lot of bigger organisations are standardising on Drupal as a platform, especially in the media industry. In other words, rather than using many different platforms (Wordpress for blogging, phpBB for forums etc), Drupal is being used as a single platform meeting many requirements. I have worked quite a lot in the media industry and this is something I have seen as well in the last few years. Adoption is increasing in not only media, but also finance, government, high tech and academic industries. Dries described the adoption of Drupal as a &lt;strong&gt;global phenomena&lt;/strong&gt;.   &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://london2011.drupal.org/scheduleitem/keynote-state-drupal&quot;&gt;See video&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;This Code Stinks!&lt;/h3&gt;
&lt;p&gt; I thoroughly enjoyed This Code Stinks! by &lt;a href=&quot;http://www.garfieldtech.com&quot;&gt;Larry Garfield&lt;/a&gt;. Larry talked about 7 common types of code smells in Drupal projects, how to detect them and how to address them. Larry was an energetic and engaging presenter who really brought the topic alive. &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://london2011.drupal.org/conference/sessions/code-stinks&quot;&gt;See video&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Node.js and Drupal&lt;/h3&gt;
&lt;p&gt; Node.js seems to be getting a lot of developers very excited. In a nutshell, it is server side Javascript using Google&amp;#39;s super fast V8 engine. The &lt;strong&gt;Node.js and Drupal talk&lt;/strong&gt; was a nice introduction to node.js and how and why to use it with Drupal. One of the presenters, Justin Randell, is using Node.js for the new version of the &lt;a href=&quot;http://drupal.org/project/chatroom&quot;&gt;chat room module&lt;/a&gt; and this was used as a great example of why node.js is useful for Drupal. &lt;/p&gt;
&lt;p&gt;  &lt;a href=&quot;http://london2011.drupal.org/conference/sessions/nodejs-and-drupal&quot;&gt;See video&lt;/a&gt;  &lt;/p&gt;
&lt;h2&gt;Other notable sessions I attended&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://london2011.drupal.org/conference/sessions/entities-emerging-patterns-usage&quot;&gt;Entities in Drupal 7&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://london2011.drupal.org/conference/sessions/bridging-gap-between-desktop-and-mobile-publishing-drupal&quot;&gt;Bridging the gap between desktop and mobile publishing with Drupal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://london2011.drupal.org/conference/sessions/damn-quick-drupal-how-make-drupal-perform-and-scale-rockstar&quot;&gt;Damn Quick Drupal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://london2011.drupal.org/conference/sessions/drush-deploy&quot;&gt;Drush Deploy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://london2011.drupal.org/conference/sessions/introduction-form-builder-new-interface-fields&quot;&gt;Form Builder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://london2011.drupal.org/conference/sessions/one-click&quot;&gt;With One Click&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://london2011.drupal.org/coreconversation/1300-1330-responsive-content-re-architecting-basic-page-render-api-etc&quot;&gt;Responsive Design - Render API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Socialising and Networking&lt;/h2&gt;
&lt;p&gt;  At any conference, networking is even more important than the sessions. Being a platform built by a community of contributors across the globe, DrupalCon is the time when everyone gets together. There was a real sense of community and buzz around the conference. There were plenty of social events during the evenings, including a pub crawl from Tower Bridge to Southwark Bridge, Batman Live and offical party in the O2 , quiz night, curry night and pub visits in Croydon. I met some very genuine and cool people and caught up with old friends and work mates. And that is what makes Drupal great - the people you meet and get to know - the community. &lt;/p&gt;
&lt;p&gt; DrupalCon London renewed my enthusiasm for Drupal. I will definitely be attending another DrupalCon soon - hopefully &lt;a href=&quot;http://denver2012.drupal.org/&quot;&gt;Denver&lt;/a&gt; or &lt;a href=&quot;http://munich2012.drupal.org/&quot;&gt;Munich&lt;/a&gt;!     &lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/drupalcon-london-2011#comments</comments>
 <category domain="http://befused.com/drupal/drupal-events">Drupal Events</category>
 <pubDate>Fri, 26 Aug 2011 09:03:47 +0100</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">240 at http://befused.com</guid>
</item>
<item>
 <title>Drush PHP memory limit</title>
 <link>http://befused.com/drupal/drush-memory-limit</link>
 <description>&lt;p&gt;With the default PHP settings, Drush will probably get a fatal error because the PHP memory limit is too low. Thankfully, the solution is very simple. &lt;!--break--&gt;&lt;/p&gt;
&lt;h2&gt;The Problem&lt;/h2&gt;
&lt;p&gt;You are using Drush and you get the following fatal error:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;Fatal error&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; Allowed memory size of &lt;span style=&quot;color: #cc66cc;&quot;&gt;33554432&lt;/span&gt; bytes exhausted &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;tried to 
allocate &lt;span style=&quot;color: #cc66cc;&quot;&gt;30720&lt;/span&gt; bytes&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; in
&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;www&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;path&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;to&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;site&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;all&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;modules&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;modulename&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;modulename&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;module 
on line &lt;span style=&quot;color: #cc66cc;&quot;&gt;1271&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;The Solution&lt;/h2&gt;
&lt;p&gt;The solution is pretty straight forward. You need to increase the memory limit in the CLI version of php.ini. You may have already increased the memory limit in the Apache2 version but forgotten about the CLI version. &lt;/p&gt;
&lt;p&gt;Assuming you are running Linux, Mac OSX or similar, open the php.ini in nano (or your preferred editor):&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;sudo nano &lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;php5&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;cli&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;php&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;ini&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Search for &lt;strong&gt;memory_limit&lt;/strong&gt;. By default, this will be set to 32MB. Increase this to 256MB and save and close the file. &lt;/p&gt;
&lt;p&gt;That is it! &lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/drush-memory-limit#comments</comments>
 <category domain="http://befused.com/drupal/troubleshooting">Drupal Troubleshooting</category>
 <pubDate>Fri, 29 Jul 2011 10:28:20 +0100</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">239 at http://befused.com</guid>
</item>
<item>
 <title>Count of duplicate values in MySQL table</title>
 <link>http://befused.com/mysql/count-duplicate-values</link>
 <description>&lt;p&gt;A client is using the Drupal node title module and, as part of an SEO review, I want to see how many duplicate meta titles there are. &lt;!--break--&gt;The following is a simple MySQL statement that I ran to get the answer:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;SELECT DISTINCT&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;page_title&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; title&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;page_title&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;AS&lt;/span&gt; &lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;count&lt;/span&gt;&lt;/a&gt; 
FROM page_title 
GROUP BY page_title 
HAVING &lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;count&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This will return a result like this:&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;title&lt;/th&gt;
&lt;th&gt;count&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buy a green widget&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buy a blue widget&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;About blue widgets&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;So in this case, the title &quot;Buy a green widget&quot; is used 2 times.&lt;/p&gt;
&lt;p&gt;This is a good example of how to get a count of duplicate values for a MySQL table.&lt;/p&gt;
</description>
 <comments>http://befused.com/mysql/count-duplicate-values#comments</comments>
 <category domain="http://befused.com/mysql">MySQL</category>
 <category domain="http://befused.com/drupal/mysql">Drupal MySQL</category>
 <pubDate>Mon, 14 Mar 2011 15:18:11 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">238 at http://befused.com</guid>
</item>
<item>
 <title>PHP max_execution_time error with Drupal and XAMPP</title>
 <link>http://befused.com/drupal/max-execution-time-error</link>
 <description>&lt;p&gt;I recently had a problem where PHP was timing out at 60 seconds when running a Drupal site using XAMPP on Windows (yeah I know, Windows and XAMPP sucks). I tried changing my php.ini file to 240 seconds, but it made no difference, it would still time out at 60 seconds. Here are the steps I made to fix this issue.&lt;!--break--&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set the php.ini max execution time to 240:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;max_execution_time &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;240&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Restarted Apache (still timing out at 60 seconds)&lt;/li&gt;
&lt;li&gt;Did a search for any other php.ini files None were found, but if they were, remove to avoid conflicts (or change the max execution time there as well)&lt;/li&gt;
&lt;li&gt;In Drupal&#039;s settings.php, add the following:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;a href=&quot;http://www.php.net/ini_set&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;ini_set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;max_execution_time&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This final step solved the issue for me. 0 sets the max execution time to unlimited&lt;/p&gt;
&lt;p&gt;If you are using PHP 5.1.3, check out this bug:&lt;br /&gt;
&lt;a href=&quot;http://bugs.php.net/bug.php?id=37306&quot; title=&quot;http://bugs.php.net/bug.php?id=37306&quot;&gt;http://bugs.php.net/bug.php?id=37306&lt;/a&gt;&lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/max-execution-time-error#comments</comments>
 <category domain="http://befused.com/php">PHP</category>
 <category domain="http://befused.com/drupal/troubleshooting">Drupal Troubleshooting</category>
 <pubDate>Mon, 15 Nov 2010 20:48:27 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">236 at http://befused.com</guid>
</item>
<item>
 <title>Revert a Drupal feature during deployment</title>
 <link>http://befused.com/drupal/revert-feature-deployment</link>
 <description>&lt;p&gt;To revert a &lt;a href=&quot;http://drupal.org/project/features&quot;&gt;features&lt;/a&gt; module during deployment, add an update hook and call features_revert with the name of the module and the component you want to revert. &lt;!--break--&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; my_module_update_6001&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
 features_revert&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;my_module&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;panels_mini&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This will revert panels_mini in the features module called &quot;my_module&quot; when you run update.php&lt;/p&gt;
&lt;p&gt;You can find the name of the components in the features .info file, as follows:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;features&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;component&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;So for a mini panel called &quot;my_mini_panel&quot;, the .info file would have this line:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;features&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;panels_mini&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;my_mini_panel&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now once you have deployed your feature to a new server, you just need to run update.php. The feature will revert to its code version. You would do this if you have changed a feature in your development environment and re-exported to code.  &lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/revert-feature-deployment#comments</comments>
 <category domain="http://befused.com/drupal/deployment">Drupal Deployment</category>
 <category domain="http://befused.com/drupal/module-development">Drupal Module Development</category>
 <category domain="http://befused.com/drupal/features">Features</category>
 <pubDate>Sun, 14 Nov 2010 20:39:24 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">235 at http://befused.com</guid>
</item>
<item>
 <title>Add an additional validation function to an existing Drupal form</title>
 <link>http://befused.com/drupal/additional-validation-function</link>
 <description>&lt;p&gt;There are many reasons why you might want to add extra validation rules to a Drupal form. This is a simple tutorial on how to add a validation function to an existing form that is generated from a module that you have not created yourself. It could be in a core or contributed module.&lt;br /&gt;
&lt;!--break--&gt; &lt;/p&gt;
&lt;h2&gt;The problem&lt;/h2&gt;
&lt;p&gt;A form has been created by another module, but we need to add additional validation.&lt;br /&gt;
&lt;!--break--&gt;&lt;/p&gt;
&lt;h2&gt;The solution&lt;/h2&gt;
&lt;h3&gt;1) Use hook_form_alter to alter the form and add an additional validation function&lt;/h3&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**
 * Implementation of hook_form_alter().
 */&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; my_module_form_alter&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$form_state&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$form_id&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
 &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form_id&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;example_form_id&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;a href=&quot;http://www.php.net/array_unshift&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array_unshift&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;#validate&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;example_validate&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
 &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a href=&quot;http://php.net/manual/en/function.array-unshift.php&quot;&gt;array_unshift&lt;/a&gt; will add the validation function to the beginning of the $form[&#039;#validate&#039;] array. This is helpful if you require other validation function to process after your new one. For example, if the form is the user login form (form ID is user_login), then the &lt;a href=&quot;http://api.drupal.org/api/function/user_login_final_validate&quot;&gt;user_login_final_validate&lt;/a&gt; function should happen last. Therefore, we wouldn&#039;t want to add a validation function to the end of the $form[&#039;#validate&#039;] array.&lt;/p&gt;
&lt;p&gt;If it doesn&#039;t matter if the validation function goes at the end of the $form[&#039;#validate&#039;] array, then the standard way to add a validation function is as follows:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;#validate&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; example_validate&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h3&gt;2) Add the custom validation function&lt;/h3&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**
 * Validate profile form
 *
 */&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; example_validate &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$form_state&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//perform some validation logic&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Working example&lt;/h2&gt;
&lt;p&gt;As an example, I want to add extra validation when a user changes his/her email address. If the new email address is the same as their existing email address, I want the form to not validation and display a validation error (since the user should add a different email address).&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**
 * Implementation of hook_form_alter().
 */&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; my_module_form_alter&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$form_state&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$form_id&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
 &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form_id&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;user_profile_form&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;a href=&quot;http://www.php.net/array_unshift&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array_unshift&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;#validate&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;email_check_validate&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
 &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**
 * Validate profile form
 * Force form error if new email address matches current email address
 *
 */&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; email_check_validate &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$form_state&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;global&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$user&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #000088;&quot;&gt;$old_email&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$user&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;mail&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #000088;&quot;&gt;$new_email&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$form_state&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;values&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;mail&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$old_email&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt;  &lt;span style=&quot;color: #000088;&quot;&gt;$new_email&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
    form_set_error&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;mail&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; t&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;Your email could not be changed&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In the above validation function, I am comparing the user&#039;s current email address, as defined by the user object of the current logged in user($user-&gt;mail), with the new email address from the form itself ($form_state[&#039;values&#039;][&#039;mail&#039;]). If they match, the user has entered the same email address as their current email address, therefore the form does not validate and the user receives an error message. &lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/additional-validation-function#comments</comments>
 <category domain="http://befused.com/drupal/module-development">Drupal Module Development</category>
 <category domain="http://befused.com/drupal/tutorials">Drupal Tutorials</category>
 <pubDate>Wed, 21 Jul 2010 14:14:32 +0100</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">233 at http://befused.com</guid>
</item>
<item>
 <title>Remove Page Titles from Panels &amp; Views</title>
 <link>http://befused.com/drupal/remove-page-titles</link>
 <description>&lt;p&gt;There may be times when you want to remove a page title from a page, but leave it as the meta title. By default, Drupal will display the node title in the h1 tag. If you take a look at page.tpl.php, you will see it there. &lt;!--break--&gt;In most themes, it will look something like this:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$title&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
   &amp;lt;h1 class=&amp;quot;page-title&amp;quot;&amp;gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$title&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&amp;lt;/h1&amp;gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;endif&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Now you may be asking why on earth would I want to remove the main page title? I will give you an example. The Panels module gives you the ability to set a title for a panel page. This title will appear in the main h1 on the page and also in the meta title tag (across the top of the browser). Because Panels brings in content from other places such as views, blocks or nodes, you may not actually want this title on the page, as each mini panel may have its own title. Sure, you can just leave the title field blank, or set it to no title. However, what if you want to keep the title for the meta title tag, but not have that title displayed in the main h1? Panels doesn&#039;t give you the ability to do that out of the box.&lt;/p&gt;
&lt;h2&gt;There is a module for that!&lt;/h2&gt;
&lt;p&gt;It is true, there is a module that handles this situation. It is called &lt;a href=&quot;http://drupal.org/project/nodewords_pagetitle&quot;&gt;nodewords pagetitle&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, there are two problems with this module:&lt;br /&gt;
1) You have to also have nodewords beta9 enabled. It will not work with the current stable version of nodewords. Upgrading to beta9 involves upgrading to beta5 first, running update.php and then upgrading to beta9 and running update.php again.&lt;br /&gt;
2) You have to add the title in a seperate admin interface. If you are already using the page title module to handle seperate meta titles for nodes, this makes your site inconsistent from a usabilty point of view. For nodes, content creators can add a sepeate node title right there on the node edit form. But for Panel or View pages, they have to go to a seperate admin screen. A recipe for confusion.&lt;/p&gt;
&lt;p&gt;So, my prefered approach, for Panels at least, is to set the title in the Panel page itself, which the Panel module allows. And then, removing the page title and associated h1 tag from the Panel page.&lt;/p&gt;
&lt;h2&gt;Removing the title options&lt;/h2&gt;
&lt;p&gt;To remove the title and the h1 tag, you have two main options:&lt;br /&gt;
1) In CSS, set display:none. I do not recommend this though. It is not good practice to set display:none to content that does exist in the html page.&lt;br /&gt;
2) Remove the title and h1 totally from the page. To do this, follow the steps below:&lt;/p&gt;
&lt;h2&gt;Removing the title and h1 solution&lt;/h2&gt;
&lt;p&gt;1) Make a list of the paths for the Panel pages&lt;br /&gt;
2) Go to the theme&#039;s template.php file&lt;br /&gt;
3) Find the pre process function for pages. If this doesn&#039;t exist, create on as such:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**
 * Hook_preprocess_page().
 */&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; theme_name_preprocess_page&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$vars&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;4) Add the following switch statement to the preprocess function:&lt;br /&gt;
In this example, I will assume the following is a list of URLs for the Panel pages where I want the title removed:&lt;br /&gt;
&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;http&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//www.example.com/page/foo&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;http&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//www.example.com/page/fi&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;http&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//www.example.com/section/zoo&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;http&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//www.example.com/bart&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//Remove title variable from certain Panel pages&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;switch&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt; arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;page&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;foo&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt; arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;page&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;fi&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt; arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;section&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;zoo&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt; arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;bart&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;
      &lt;a href=&quot;http://www.php.net/unset&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;unset&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$vars&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;title&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
      &lt;span style=&quot;color: #b1b100;&quot;&gt;break&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;In the switch statement, if the case returns TRUE, then the code to unset the page title will be executed. Therefore, for those pages, the title will be removed totally from the page. Because the title variable is unset, the main h1 element will also not appear.  That is assuming that it is wrapped in a condition that checks for the title variable. Here is a repeat of the code past at the beginning of this post, which shows that:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$title&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
   &amp;lt;h1 class=&amp;quot;page-title&amp;quot;&amp;gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$title&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&amp;lt;/h1&amp;gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;endif&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Therefore, because $title has been unset, the condition here will return false, and the h1 element will not be displayed. But it will remain as a meta title, which is exactly what we want. &lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/remove-page-titles#comments</comments>
 <category domain="http://befused.com/drupal/theming">Drupal Theming</category>
 <pubDate>Wed, 30 Jun 2010 14:00:24 +0100</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">232 at http://befused.com</guid>
</item>
<item>
 <title>Drupal base URL for hard coded images on a local environment</title>
 <link>http://befused.com/drupal/base-url-images</link>
 <description>&lt;p&gt;&lt;strong&gt;EDITED 10 AUG 2010: &lt;/strong&gt; There is an alternative solution on Drupal Coder (as kindly pointed out in one of the comments). I&#039;d recommend checking it out: &lt;a href=&quot;http://www.drupalcoder.com/story/18-portable-sites-with-base-href-baseurl-in-drupal&quot; title=&quot;http://www.drupalcoder.com/story/18-portable-sites-with-base-href-baseurl-in-drupal&quot;&gt;http://www.drupalcoder.com/story/18-portable-sites-with-base-href-baseur...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Images paths are often incorrect when developing/testing a Drupal website on a local machine. &lt;!--break--&gt;&lt;br /&gt;
Lets assume images are located in the following folder: sites/all/files. Lets assume that you have hard-coded an image element into a view header. You would use something like this:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;img src&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;/sites/all/files/myimage.jpg&amp;quot;&lt;/span&gt; alt&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;my alt tag&amp;quot;&lt;/span&gt; width&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;100&amp;quot;&lt;/span&gt; height&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;200&amp;quot;&lt;/span&gt;  &lt;span style=&quot;color: #339933;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;On a live website with a domain name of example.com, the full path for the image will be: &lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;example&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;com&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;all&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;files&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;myimage&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;jpg&lt;/code&gt;&lt;/span&gt; . &lt;/p&gt;
&lt;p&gt;If you have a copy of that site running locally, then your site url might be &lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;http&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//localhost/workingcopy/websites/example&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;. As far as your local webserver is concerned, localhost is your root. So i will use the following path for displaying our image: &lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;http&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//localhost/sites/all/files/myimage.jpg&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;, which is incorrect as it is missing &lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;geshifilter-php&quot;&gt;workingcopy&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;websites&lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt;example&lt;/code&gt;&lt;/span&gt;. &lt;/p&gt;
&lt;p&gt;Remedy:&lt;/p&gt;
&lt;p&gt;1) in settings.php, set the base url variable.&lt;br /&gt;
Example:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$base_url&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;http://localhost/workingcopy/websites/example&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;2) In the image element, add the base url variable, as follows:&lt;br /&gt;
Example:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&amp;lt;img src=&amp;quot;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;global&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$base_url&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$base_url&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;/sites/all/files/myimage.jpg&amp;quot; alt=&amp;quot;some alt text&amp;quot; width=&amp;quot;100&amp;quot; height=&amp;quot;200&amp;quot;  /&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/base-url-images#comments</comments>
 <category domain="http://befused.com/drupal/tutorials">Drupal Tutorials</category>
 <pubDate>Wed, 31 Mar 2010 22:24:19 +0100</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">231 at http://befused.com</guid>
</item>
<item>
 <title>Tag nodes from a content type with a taxonomy term</title>
 <link>http://befused.com/drupal/tag-nodes-taxonomy-term</link>
 <description>&lt;p&gt;Lets assume that you have a bunch of nodes for a content type and you want to tag them all with the same taxonomy term. First, find the term ID of the relevant term. In example, the term ID is 103 and the content type is &quot;contact&quot;. &lt;/p&gt;
&lt;p&gt;This is an example if an &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.1/en/insert-select.html&quot;&gt;&lt;strong&gt;insert ... select&lt;/strong&gt;&lt;/a&gt; statement.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;INSERT INTO term_node &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;nid&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; vid&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; tid&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;
SELECT nid&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; vid&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;103&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; tid
FROM `node`
WHERE TYPE &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;contact&#039;&lt;/span&gt;
AND language &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;en&#039;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/tag-nodes-taxonomy-term#comments</comments>
 <category domain="http://befused.com/drupal/mysql">Drupal MySQL</category>
 <category domain="http://befused.com/drupal/taxonomy">Drupal Taxonomy</category>
 <pubDate>Mon, 30 Nov 2009 16:15:19 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">229 at http://befused.com</guid>
</item>
<item>
 <title>Drupal redirect in .htaccess</title>
 <link>http://befused.com/drupal/redirect-htaccess</link>
 <description>&lt;p&gt;Using .htaccess is one of the best ways to redirect a URL to a new URL. Particular care needs to be taken with Drupal sites for it to work correctly.&lt;!--break--&gt;&lt;/p&gt;
&lt;p&gt;The following snippets needs to be added to the root .htaccess file directly after the following lines:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Various rewrite rules.
&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;IfModule mod_rewrite&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;
  RewriteEngine on
  &lt;span style=&quot;color: #339933;&quot;&gt;.......&lt;/span&gt;
  &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# If your site is running in a VirtualDocumentRoot at &amp;lt;a href=&amp;quot;http://example.com/,&amp;lt;br /&amp;gt;
&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot; title=&amp;quot;&lt;/span&gt;http&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//example.com/,&amp;lt;br /&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;&amp;gt;http://example.com/,&amp;lt;br /&amp;gt;
&amp;lt;/a&amp;gt;  # uncomment the following line:
  # RewriteBase /&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;#custom redirectsRewriteRule ^oldpath$ &amp;lt;a href=&amp;quot;http://www.example.com/newpath&amp;quot; title=&amp;quot;http://www.example.com/newpath&amp;quot;&amp;gt;http://www.example.com/newpath&amp;lt;/a&amp;gt; [R=301,L]
&lt;/span&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;#end custom redirects&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a href=&quot;http://pingv.com/blog/laura/200511/creating-301-redirects-for-drupal&quot;&gt;More info on Ping Vision&lt;/a&gt;&lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/redirect-htaccess#comments</comments>
 <category domain="http://befused.com/drupal/htaccess">Drupal htaccess</category>
 <pubDate>Wed, 11 Nov 2009 15:30:05 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">228 at http://befused.com</guid>
</item>
<item>
 <title>Drupal link function</title>
 <link>http://befused.com/drupal/link-function</link>
 <description>&lt;p&gt;The Drupal link function is a handy and easy way to create hyperlinks in your module or theme.&lt;br /&gt;
&lt;!--break--&gt;&lt;br /&gt;
The syntax for the link function is:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; l&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;em&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;anchor text&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;em&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;em&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;path&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;em&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This is an example of a simple link that might exist in a theme template file:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; l&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;See full post&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;node/&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$node&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;nid&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The above example would create the following hyper link (assuming that the given $node-&gt;nid is 1):&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;a href&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;node/1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;See full post&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Attributes&lt;/h2&gt;
&lt;p&gt;You can easily add attributes to the link.&lt;br /&gt;
For example, lets say you want to add a class to your anchor link called &quot;see-more&quot; and&lt;br /&gt;
you want to add target=&quot;_blank&quot;&lt;/p&gt;
&lt;p&gt;Drupal 5:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$attributes&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;class&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;see-more&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;target&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;_blank&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; l&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;See full post&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;node/&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$node&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;nid&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$attributes&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Drupal 6:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&amp;nbsp;
&lt;span style=&quot;color: #000088;&quot;&gt;$options&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;attributes&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;class&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;see-more&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;target&#039;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;_blank&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; l&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;See full post&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;node/&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$node&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;nid&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$options&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;The above examples would create the following hyper link:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;a href&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;node/1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;see-more&amp;quot;&lt;/span&gt; target&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;_blank&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;See full post&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h3&gt;External links&lt;/h3&gt;
&lt;p&gt;If the link is external, then use the full URL including the http://.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;print&lt;/span&gt; l&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;Google&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;http://www.google.com&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This would create:&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;php geshifilter-php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;a href&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;&amp;quot;http://www.google.com&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;Google&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;h2&gt;Why bother?&lt;/h2&gt;
&lt;p&gt;It is generally easier to create a hyper link using the link l() function that typing out the full html for an anchor link.&lt;br /&gt;
Using the link function is more secure because check_plain and check_url will run automatically, which helps prevent xss attacks.&lt;br /&gt;
And finally, active classes are automatically assigned when using the link function. &lt;/p&gt;
&lt;p&gt;For more information, see the Drupal API page on the &lt;a href=&quot;http://api.drupal.org/api/function/l/5&quot;&gt;Drupal link function&lt;/a&gt;&lt;/p&gt;
</description>
 <comments>http://befused.com/drupal/link-function#comments</comments>
 <category domain="http://befused.com/drupal">Drupal</category>
 <category domain="http://befused.com/drupal/drupal-functions">Drupal Functions</category>
 <category domain="http://befused.com/drupal/module-development">Drupal Module Development</category>
 <pubDate>Thu, 05 Nov 2009 21:42:44 +0000</pubDate>
 <dc:creator>Blair Wadman</dc:creator>
 <guid isPermaLink="false">227 at http://befused.com</guid>
</item>
</channel>
</rss>
