Experimental Project

This is a sandbox project, which contains experimental code for developer use only.

An experimental sandbox to convert paths with query parameters to prettier ones: e.g.: my-view?page=1 => myview/page-1.

Purpose

This module provides a configuration for prettifying paths. Prettifying means to
replace query parameters with parts of the path. You e.g. may want to append the
page number to the path, isntead of carrying as query param.

Altering paths this way, may not have a big impact on SEO, so most times it may
not be worth the effort to deal with maybe occuring side effects. But if you
need exactly that behaviour, try this module and please give feedback, so we may
know what pitfalls this approach comes with.

Settings

The module is configured via hook_prettypath_config().

Example:

  • ?type=article will be replaced and appended as /type-article
  • ?page=15 will be replaced and appended as /page-15
/**
 * Implements hook_prettypath_config().
 */
function mycustom_prettypath_config() {
  $config = array(
    'path' => '*',
    'segments' => array(
      array(
        'segment position' => 'auto',
        'type' => 'single',
        'force' => TRUE,
        'prefix' => 'type-',
        'items' => array(
          array(
            'item' => array(
              'type' => 'facet',
              'facet' => 'type',
            ),
          ),
        ),
      ),
      array(
        'segment position' => 'auto',
        'type' => 'single',
        'force' => TRUE,
        'prefix' => 'page-',
        'items' => array(
          array(
            'item' => array(
              'type' => 'get',
              'key' => 'page',
            ),
          ),
        ),
      ),
    ),
  );
  return array($config);
}

Known Issues

Project Information