Hi there.
I have a view set up with a contextual filter to display articles grouped by entity reference. I used this code:
// $argument will contain the argument provided in the URL
// Check to see if the argument is already numeric
// Useful with views Preview
if (is_numeric($argument)) {
return TRUE;
}
// Check to see if wildcard is used
elseif ($argument == 'all') {
return TRUE;
} else {
// Find the drupal path that the argument represents
$path = drupal_lookup_path('source', $argument);
if ($path) {
// If there is a match then we have found the node source path.
// Select the second element of the node source path as this will contain the node id and
// set the argument that is passed back to the view to this value.
$result = explode("/", $path);
if ($result[0] == 'node' && is_numeric($result[1])) {
$handler->argument = $result[1]; // This changes the value of the argument the view uses.
return TRUE; // Indicate that this argument validated.
}
}
}
return FALSE; // Otherwise, indicate that the argument did not validate.
The page is accessible either by /articles/1 (where 1 is the nid of the entity being referenced) or by /articles/entity (where entity is the value of the entity itself :P)
I want to add a read more link, but whether I go for a vanilla link of specify a custom URL, it always links to page via /articles/1. How can I make it link via /articles/entity ???
Comments
Comment #1
mustanggb commentedClosing this as outdated, feel free to re-open if you're still looking for a solution and waiting for appropriate assistance.