CEO of comm-press GmbH and total Drupal evanglist.

SEO-friendly URL

Multiple Panel variants for one node with SEO friendly paths

Today we had the problem that we did need multiple panel display variants for the same node.

If you wanted to display a nodes comments or maybe a cck multiple imagefield in its own view you would have to build urls like "node/123/comments" or "node/123/images". Panels can easily do this by creating a panel like "node/%/comments". But it would be nice if we could use a path alias like "dog/odin/images". Panels and views might be able to use a nodes title as argument but the path alias would be rewritten to be URL conform.

Gladly we can use smk-ka's module Subpath Alias. This module extends the URL alter Modul and extends the alias of a node. By this a given path "dog/odin/images" translates into "node/123/images" and we can easily access the integer id of the node again to build our data.

We now can setup a panel for "node/%node". Than we can add a variant filters for the nodetype "dog" and a PHP snippet. Use this snippets for an eval() call. Be sure not to use < ? php and ? >.

<?php
return drupal_match_path($_GET['q'], '*/images');
?>

drupal_match_path() is a very useful function that you might know because the block system uses it for URL matching. If this evaluates to true and the nodetype fits the panel variant will be used. By this we now can use panels or views with easy integer arguments but show SEO friedly URLs to the world. The only thing we now need to add are some context sensitive links so the user can easily navigate the site and benefit from this..

Kommentare

Ralf Hendel - Tue, 05/17/2011 - 09:14
<p>Hello Ben,</p><p>it does no matter which way you choose to rewrite or construct your links. You can do this via custom modules, rewriting links via views or manage this manually.</p><p>The trick is, that drupal "understands" those links and could display different panel variants according to path-suffix.</p><p>Hope that helps,</p><p>Ralf</p>
Ben - Thu, 05/05/2011 - 13:50
Hi. In your article you mention that this is a relatively easy thing to do: - - - - to build urls like "node/123/comments" or "node/123/images" Panels can easily do this by creating a panel like "node/%/comments" - - - - I have scoured the web for the answer to this but have come up short. I am running Drupal 7 with Panels 3. I have built two variants of the node page (one for a group date field with traditional output view and another for the same group date field with fullcalendar view). Where I am having trouble is finding a unique url for at least one of these variants (Ideally the fullcalendar view so that the traditional view can be the default place that users land when they click on a group link anywhere on the website). Can you please tell me how to build these sub page urls? Many thnx in advance. Ben
Gast - Fri, 10/08/2010 - 17:32
AWESOME! That saved my day! It was even enough to just enable the upper modules and it worked, since i have the node-type as displayfilter, which is enough for my panel. But all arguments are recognized now - yummy!