Views direct link
Component ID
1470082
Component name
Views direct link
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
Provides a link one can copy-paste to share a link to filtered results of a view. Especially useful when using Views with AJAX enabled, where the "real" URL is hidden.
This module currently works with exposed filters only.
How to use
1. Enable the generation of the direct link somewhere in the views process, like in hook_views_pre_build()
function mymodule_views_pre_build(&$view) {
if ($view->name == 'myview' && $view->current_display == 'mydisplay') {
$view->views_direct_link_enabled = TRUE;
}
}
2. Generate the link in the theme layer. The module provides a theme_views_direct_link() helper, but you can do what you want.
function mytheme_preprocess_views_view(&$vars) {
if (isset($vars['view']->views_direct_link)) {
$vars['direct_link'] = theme_views_direct_link($vars['view']->views_direct_link['path'], $vars['view']->views_direct_link['query']);
}
}
3. Display the generated output in your template (for instance views-view--myview.tpl.php).
<?php if (isset($direct_link)): ?>
<div class="views-direct-link">
<?php print $direct_link; ?>
</div>
<?php endif; ?>
