Growing Venture Solutions - GVS - clean urls http://growingventuresolutions.com/taxonomy/term/30/0 en Preparing a Drupal site for efficient support http://growingventuresolutions.com/blog/preparing-drupal-site-efficient-support <h3>We can support your Drupal site, but first let&#8217;s make it right</h3> <p>When we first offered <a href="about/services/drupal-support">formal Drupal Support services</a> we expected clients would know their site fairly well and need help with advanced administration and/or doing &#8220;new&#8221; things. In practice, we&#8217;ve quickly learned an important lesson about the diversity of Drupal site owners. Some are virtuosos, and need our help with very complex issues. Some have an existing site with major deficiencies, perhaps built by a vendor who is no longer in the picture. Some need some tutoring in Drupal basics, or even the concepts of dynamic websites.</p> <p>So we have learned to sort out from the start whether clients will need a more intensive initial phase that includes a site review, an assessment of how well administrators and users understand their Drupal site, and quite possibly a detailed site tune-up. Here is how the technical side went with one client &#8230;</p> <!--break--><!--break--><p>From the outset, we sensed all of this client&#8217;s support hours could be consumed just trying to stay ahead of the ad hoc techniques used in the construction and management of the site. We knew we had to stabilize the situation so the client could get more value from our support &#8212; and from their site. We found the site running an older version of Drupal 5 on a Windows IIS host with only FTP (not SFTP nor ssh) access for managing the site. The clients wanted to improve SEO and feel more in control. They weren&#8217;t really using Drupal as a content management system.</p> <h3>First steps in Drupal site evaluation</h3> <p>To move forward, and protect their investment in the site, we helped the client to arrange for Linux hosting and planned an upgrade to Drupal 6. In short, this would put them on a version that is easier to support, simplify setup of clean URLs and guarantee availability of security updates beyond the Drupal 7 horizon. Using a Linux host with ssh access is a strong preference for our team; it makes our work for clients more efficient.</p> <p>We prepared to migrate and upgrade the site by reviewing the site&#8217;s:</p> <ul> <li>32 contributed modules,</li> <li>four custom themes (hacked versions of Garland applied to specific pages via <a href="http://drupal.org/project/taxonomy_theme">Taxonomy Theme</a>),</li> <li>structure including menus, content types, views and input filters,</li> <li>status of existing content, including some content not linked into site navigation at all,</li> <li>non-Drupal static pages and a Wordpress installation on the same domain, all themed to appear as part of the main site.</li> </ul> <h3>Getting a handle on a Drupal site&#8217;s modules</h3> <p>Our review found that 20 of the contributed modules had no significant purpose on the site, plus two useful modules weren&#8217;t supported for Drupal 6. While the site was functional, under the hood there were overlapping and partially configured modules, as if the previous site builder had left in the middle of some hasty experiments. In some cases we had to query the <em>variable</em> table or the tables associated with a module to be sure whether it was in use.</p> <p>With all of the unneeded modules gone, we added <a href="http://drupal.org/project/token">Token</a>, <a href="http://drupal.org/project/pathauto">Pathauto</a> and <a href="http://drupal.org/project/globalredirect">Global Redirect</a> to set the stage for SEO improvements.</p> <p>Some modules were needed but not supported in Drupal 6. We replaced <a href="">Taxonomy Theme</a> with <a href="http://drupal.org/project/themekey">Theme Key</a>, and <a href="http://drupal.org/project/tinymce">Tiny MCE</a> with <a href="http://drupal.org/project/wysiwyg">Wysiwyg API</a> configured with the <a href="http://tinymce.moxiecode.net/download_i18n.php">TinyMCE 3 plug-in</a> (per the client&#8217;s preference).</p> <h3>Untangling and upgrading Drupal themes</h3> <p>We upgraded the themes to Drupal 6, referring to the <a href="http://drupal.org/node/132442">Converting 5.x themes to 6.x checklist</a> as well as some tips that simplified the process on <a href="http://wtanaka.com/drupal/convert-theme-6">Wesley Tanaka&#8217;s blog</a>. The themes interacted with Nice Menus via <a href="http://api.drupal.org/api/function/theme_menu_item_link/6">theme_menu_item_link</a>, an API function whose definition has changed sufficiently in Drupal 6 that it no longer suited the purpose. <a href="http://drupal.org/project/nice_menus">Nice Menus</a> in Drupal 6 has configuration options that bridged the gap. Theme_menu_item_link was still helpful, though, because the Drupal 5 site contained menu entries which linked nowhere, something Drupal 6 doesn&#8217;t allow. We addressed this in the theme layer with an approach modeled after <a href="http://drupal.org/node/143322">this suggestion by tekket</a>.</p> <p>Once we had sorted through the content and knew which pages were actually live (versus published but not linked from anywhere). We realized one of the themes wasn&#8217;t in use at all. Another turned out to only be used when a certain region shouldn&#8217;t appear, but that region would suppress itself if no blocks were assigned. So it wasn&#8217;t too hard to prune the themes to one for the home page and one more for the rest of the site.</p> <h3>Getting bugs out of the content</h3> <p>Having reviewed and simplified the site configuration, the Drupal 6 upgrade itself went very much by the book. A few of the remaining modules needed a 2.x upgrade while still in Drupal 5 to make ready for Drupal 6. Since the client was making few content changes, the upgraded site could be brought up on the new host and reviewed before changing DNS, simplifying the staging process. Site content upgraded cleanly with a few exceptions. Views import worked, but much of the detail of the views had to be reconstructed anyway.</p> <p>The menus and some of the content had hard-coded references to pages and images on the site without using relative links or clean URLs, and even sometimes linked by IP address. We used queries into the <em>node_revisions</em> and <em>menu_links</em> tables to find what needed fixing. There were few enough problem nodes that it made the most sense to fix them manually, but Greg made a time-saving suggestion &#8212; use a calculation in an ad hoc query to output the complete node/#/edit URL for each node to update. From there (from the mySQL command-line in a Mac OS X iTerm window), I selected the URL from the query output and usied a keyboard shortcut assigned to the Open URL entry in the service menu. Tricks like these can make even a modest manual process take half the time or less.</p> <p><img src="http://growingventuresolutions.com/gvsfiles/mysql_query_concatenation.png" alt="A query with quick links to content that needs to be updated" /></p> <h3>The result: a smoothly-running Drupal site</h3> <p>None of this work was glamorous, but the result is very satisfying &#8212; the site is now in much better shape. The review helped the client know their site better, and we are poised to start doing some real support, such as making the site&#8217;s themes more configurable, adding templates to replace some of the static pages and helping the client manage their own content. The site is stable and its configuration will be much more comprehensible should another Drupal pro need to work with it in the future.</p> http://growingventuresolutions.com/blog/preparing-drupal-site-efficient-support#comments Planet Drupal clean urls globalredirect module path_redirect support Sat, 11 Apr 2009 13:18:42 +0000 steve harley 419 at http://growingventuresolutions.com Build Your Own TinyURL With Drupal AND Everything You Need to Know About Paths in Drupal http://growingventuresolutions.com/blog/build-your-own-tinyurl-drupal-and-everything-you-need-know-about-paths-drupal <p>Drupal has some pretty amazing features to handle aliases and aliasing. They are also commonly misunderstood. This article is an attempt to shed some light on how URLs and aliases and redirects work in Drupal which, with the help of some contributed modules, automatically turn a Drupal site into a TinyURL-like service.</p> <h3>It All Starts With the Menu System</h3> <p>Most modules in Drupal have a <a href="http://api.drupal.org/api/function/hook_menu">hook into the menu system</a> which allows them to declare paths to which they will respond. For example, the node module's hook to the menu system allows it to respond to requests for "/node/".</p> <h3>Clean URLs vs. ... Dirty? URLs</h3> <p>Drupal responds to the "q" parameter from the URL. <a href="http://growingventuresolutions.com/?q=node/1">http://growingventuresolutions.com/?q=node/1</a> tells Drupal to serve up the page for "node/1". Ever since about <a href="http://cvs.drupal.org/viewvc.py/drupal/drupal/.htaccess?r1=1.43&amp;r2=1.44">2003</a> Drupal has used features of the web server so that <a href="http://growingventuresolutions.com/?q=node/1">http://growingventuresolutions.com/?q=node/1</a> can be "rewritten" to <a href="http://growingventuresolutions.com/node/1">http://growingventuresolutions.com/node/1</a>. This is the so-called "Clean URL" which removes the main query parameter from every Drupal page request. Sure, there are still some page requests like for the <a href="http://growingventuresolutions.com/blog?page=1">second page in a list of nodes</a> but they are much less common.</p> <p>Ever since Drupal 6.x, if your web server supports clean urls then they will be enabled during installation. This is great.</p> <h3>Internal Path vs. Path Alias</h3> <p>In various administration screens and documentation Drupal uses the phrase "internal path" or "system path" or "Drupal path" to mean things like <a href="http://growingventuresolutions.com/node/1">node/1</a> or <a href="http://growingventuresolutions.com/taxonomy/term/1">taxonomy/term/1</a>. This is in contrast to a path alias like those provided by the Drupal Core <a href="http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/path/">Path</a> module. Let me reiterate: <em>Drupal Core <a href="http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/path/">Path</a> module</em>. Drupal core lets you create any <em>alias</em> for any system path. On this site <a href="http://growingventuresolutions.com/about">about</a> is the alias for <a href="http://growingventuresolutions.com/node/1">node/1</a>.</p> <p><em>You can have multiple aliases for one internal path, but it is not recommended</em>. This is confusing, both to your users and search engines, to have the same content available at two paths. The problem is not limited to creating multiple aliases for a single internal path. Even having just the alias and the internal path creates multiple URLs for the same content. For solutions to both of these problems, see below.</p> <p>Of course you don't want to build your own alias for every path so you use something like <a href="http://drupal.org/project/pathauto">Pathauto</a> to create your aliases for you. These are additions to the Drupal core modules, but they simply extend the features of the core Path module.</p> <h3>user/1 vs. members/admin - What does Drupal see?</h3> <p>If you have created an alias (manually or via Pathauto, no difference) so that the internal path of "user/1" is accessible via the alias "members/admin" what does Drupal actually see? The answer depends on the context of the question. For block visibility rules and a few other things, the rules are checked against both "user/1" and "members/admin" to determine which blocks to show. However, the <a href="http://api.drupal.org/api/function/arg">arg</a> function only sees the internal values so that for a user visiting "members/admin" arg(0) is "user" and arg(1) is "1".</p> <h3>Extending Pathauto for Other Things (like Views!)</h3> <p>Pathauto only creates aliases for paths based on the system paths used in Drupal core for nodes, users, and taxonomies. This leaves arbitrary URLs that accept node IDs, user ids, and term IDs without any solution (and by arbitrary URLs I'm of course thinking of <a href="http://drupal.org/project/views">Views</a> and <a href="http://drupal.org/project/panels">Panels</a>. It would be possible to write a plugin to Pathauto that uses the <a href="http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/pathauto/API.txt">Pathauto API</a> and a little custom code to build aliases for Views or Panels. Unfortunately it is fairly difficult to write such a plugin in a generalized way. That remains a topic for a future blog post...</p> <h3>WWW or no-www</h3> <p>Do you use a www in front of your url or not? This is up to your personal preferences. My advice is that sites focused on less savvy visitors should use the "www" in the front of the domain while the wave of the future is to get rid of www. Regardless of which you choose (and you should choose one) Drupal's core .htaccess file provides an example of how to redirect from one to the other. But, if you want a tiny url, then ommitting it (or at least redirecting it) is a good idea. See <a href="http://growingventuresolutions.com/blog/should-i-use-www-my-website-address">this old blog post</a> for more discussion.</p> <h3>Path Redirection and Global R</h3> <p>These two modules that provide some additional benefits for most sites.</p> <p><strong><a href="http://drupal.org/project/path_redirect">Path Redirect</a></strong> allows site admins to create redirects. Unlike aliases, redirects send the visitor to a new page using an HTTP 3xx redirect code. This is a benefit when you want <strong>two paths to work for the same content without the duplication problems mentioned earlier.</strong> While Path Redirect provides all the 3xx redirects, the most common and recommended one is a 301 redirect. <strong>When Path Redirect is installed, Pathauto will present a new "Update action" for situations where a URL changes to create a new alias and redirect from the old alias. This is the recommended configuration.</strong></p> <div style="float: right"><img src="http://growingventuresolutions.com/gvsfiles/pathauto_path_redirect.png" /></div> <p><strong><a href="http://drupal.org/project/globalredirect">Global Redirect</a></strong> removes the duplicate content problems created in other parts of Drupal such as the "?q=node/1" vs. "node/1" vs. "about" on this site. You may have noticed earlier that while the links I created in this article pointed to the "Dirty URL" or the "internal path" for the page the browser was redirected to the one true alias for a page. That is the work of the very useful Global Redirect module. It provides several benefits and has very little impact on performance or user interface which makes Global Redirect a "must have" on most every site.</p> <h3>Building a Site-Specific TinyURL Feature with Drupal</h3> <p>There are many sites around the internet like <a href="http://tinyurl.com/">TinyURL</a> or <a href="http://notlong.com/">NotLong</a> which provided shortened links to really long urls. Links provide an opportunity for branding and building trust - why outsource this function to third party services when you can build it yourself?</p> <p>If you made it this far you already know the answer to the question of "how to build tinyurl with Drupal"</p> <ol> <li>Start with a short domain name - maybe one that is a shortened version of your normal name.</li> <li>Remove the www from the front of it.</li> <li>Use the "node/nid" url instead of the alias</li> <li>Celebrate!</li> </ol> <p>For example, this story is also accessible at <a href="http://growvs.com/node/243">http://growvs.com/node/243</a>.</p> <ul> <li>From <a href="http://growvs.com/node/243" title="http://growvs.com/node/243">http://growvs.com/node/243</a> the DNS system forwards to <a href="http://growingventuresolutions.com/node/243" title="http://growingventuresolutions.com/node/243">http://growingventuresolutions.com/node/243</a></li> <li>From <a href="http://growingventuresolutions.com/node/212" title="http://growingventuresolutions.com/node/212">http://growingventuresolutions.com/node/212</a> you get forwarded to the aliased version of the page by Global Redirect</li> </ul> <p>Yay!</p> <p><em>P.S. My thanks to <a href="http://www.angrydonuts.com/">merlin</a> and <a href="http://www.ezra-g.com/">ezra-g</a> for their reviews of this post.</em></p> http://growingventuresolutions.com/blog/build-your-own-tinyurl-drupal-and-everything-you-need-know-about-paths-drupal#comments Planet Drupal clean urls globalredirect pathauto path_redirect Thu, 29 Jan 2009 01:47:11 +0000 Greg 243 at http://growingventuresolutions.com