You are here

function _nodewords_prepare_path in Nodewords: D6 Meta Tags 6

Provide a complete path for the current URL, optionally using a value manually assigned via a form.

Parameters

$content: An array of settings for this current field, optionally including the manually assigned path.

$options: An array of options for this current page.

Return value

Fully qualified absolute URL for the current page.

2 calls to _nodewords_prepare_path()
nodewords_basic_canonical_prepare in nodewords_basic/nodewords_basic.module
Use the common function for compiling the current URL.
nodewords_og_og_url_prepare in nodewords_og/nodewords_og.module
Use the common function for compiling the current URL.

File

./nodewords.module, line 1559
Implement an API that other modules can use to implement meta tags.

Code

function _nodewords_prepare_path($content, $options) {

  // Need to compare the value against system base path.
  $base_path = base_path();

  // Remove the base path from the front of the URL.
  if (!empty($content['value']) && strpos($content['value'], $base_path) === 0) {
    $content['value'] = drupal_substr($content['value'], drupal_strlen($base_path));
  }

  // Start with a system path.
  if (empty($content['value'])) {
    $path = '';
    switch ($options['type']) {
      case NODEWORDS_TYPE_FRONTPAGE:
        $path = '<front>';
        break;
      case NODEWORDS_TYPE_NODE:
        $path = 'node/' . $options['id'];
        break;
      case NODEWORDS_TYPE_PAGE:
        $path = $_GET['q'];
        break;
      case NODEWORDS_TYPE_TERM:

        // Accommodate other modules that change the path via hook_term_path().
        $term = taxonomy_get_term($options['id']);
        $path = module_invoke('taxonomy', 'term_path', $term);
        break;
      case NODEWORDS_TYPE_USER:
        $path = 'user/' . $options['id'];
        break;
    }
    if (!empty($path)) {
      $content['value'] = $path;
    }
  }
  if (!empty($content['value'])) {
    return check_url(nodewords_url($content['value'], $options));
  }
  else {
    return '';
  }
}