i18n_page_views.module in i18n page views 6
File
i18n_page_views.module
View source
<?php
function i18n_page_views_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'i18n_page_views') . '/includes',
);
}
function i18n_page_views_views_pre_build(&$view) {
if (strstr($view->current_display, 'i18n_page') && !$view->preview) {
global $language;
$arg = arg();
$views_args = array();
$path = explode('/', $view->display[$view->current_display]->display_options['path_' . $language->language]);
foreach ($path as $pos => $unit) {
if ($unit == '%') {
$view_args[] = $arg[$pos];
}
}
$view->args = $view_args;
}
}
function i18n_page_views_context_plugins() {
$plugins = array();
$plugins['context_condition_i18n_views'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'i18n_page_views'),
'file' => 'context_condition_i18n_views.inc',
'class' => 'context_condition_i18n_views',
'parent' => 'context_condition',
),
);
return $plugins;
}
function i18n_page_views_context_registry() {
return array(
'conditions' => array(
'context_condition_i18n_views' => array(
'title' => t('i18n Views'),
'plugin' => 'context_condition_i18n_views',
'description' => t('Set this context when displaying the page of one of these i18n views.'),
),
),
);
}
function i18n_page_views_views_pre_view($view, $args) {
if (module_exists('context')) {
if ($plugin = context_get_plugin('condition', 'context_condition_i18n_views')) {
$plugin
->execute($view);
}
}
}