views_url_path_arguments.module in Views URL Path Arguments 7
Main file for the Views URL Path Arguments module, which automatically converts url path aliases for views arguments.
File
views_url_path_arguments.moduleView source
<?php
/**
* @file
* Main file for the Views URL Path Arguments module,
* which automatically converts url path aliases for views arguments.
*/
/**
* Implements hook_help().
*/
function views_url_path_arguments_help($path, $arg) {
switch ($path) {
case 'admin/help#views_url_path_arguments':
$output = '<h3>' . t('Overview') . '</h3>';
$output .= '<p>' . t("Simple module to convert a view contextual filter node id into its url path.") . '</p>';
$output .= '<p>' . t("Extended use case: A website has a view that uses node reference or entity reference to filter the results set. For example, a regional location node is a node reference on a bunch of news stories. The view is setup to filter and show only news stories in the Chicago region and not any news stories from any other regions. Rather than using nid for the contextual filter (which isn't SEO friendly) these plugins allow the ability to use SEO friendly url path / path alias.") . '</p>';
$output .= '<p>' . t('Example:') . '</p>';
$output .= '<pre>www.example.com/news-stories/chicago';
$output .= PHP_EOL . "\t\t\t\t\t\t\t^^" . t('path alias argument');
$output .= PHP_EOL . "\t\t\t\t\t\t\t" . t('chicago converts to a nid for normal views contextual filter processing') . '</pre>';
$output .= '<h3>' . t('Configuration') . '</h3>';
$output .= '<p>' . t("There are two plugins available in this module. The default argument plugin should be used with blocks or things that don't naturally have arguments available to them. The validator plugin should be used to convert the nid for views that naturally have arguments available to them, such as pages. They can be used together if a view is rendered in both a block and a page. Or seperately if the site's view is rendered only as a page or only as a block.") . '</p>';
$output .= '<ul>';
$output .= '<li>' . t("Configure contextual filters in Administration » Structure » Views » view: Add a contextual filter i.e. Content: Nid") . '</li>';
$output .= '<ul>';
$output .= '<li>' . t('Argument not available to views? Use: When the filter value is not available » Provide default value » URL path alias from URL') . '</li>';
$output .= '<li>' . t('Argument available to views? Use: When the filter value is available or a default is provided » Specify validation criteria » Validate URL path alias') . '</li>';
$output .= '</ul></ul>';
return $output;
}
}
/**
* Implements hook_views_api().
*/
function views_url_path_arguments_views_api() {
return array(
'api' => 3,
);
}
Functions
Name | Description |
---|---|
views_url_path_arguments_help | Implements hook_help(). |
views_url_path_arguments_views_api | Implements hook_views_api(). |