Commit f02546ef authored by Martin Leblanc's avatar Martin Leblanc
Browse files

Merge branch 'feature/ISTWCMS-5501-ebremner-ical-feed' into '1.0.x'

Feature/istwcms 5501 ebremner ical feed

See merge request !51
parents 9f726cb0 3570069e
......@@ -9,6 +9,26 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\views\ViewExecutable;
/**
* Implements hook_preprocess_node().
*/
function uw_ct_event_preprocess_node(&$variables) {
// If on an event, add the ical link.
if ($variables['node']->getType() == 'uw_ct_event') {
// Get the nid.
$nid = $variables['node']->id();
// Get the URL to ical feed.
$ical_url = Url::fromRoute('view.uw_view_events.events_ical');
$ical_url = $ical_url->toString() . '/' . $nid;
// Add the ical url to the variable so can be used on templates.
$variables['ical'] = $ical_url;
}
}
/**
* Implements hook_views_pre_view().
*/
......@@ -36,6 +56,14 @@ function uw_ct_event_views_pre_view(ViewExecutable $view, $display_id, array &$a
// Set the variable to the RSS.
$view->rss = $rss;
// Get the URL to ical feed.
$ical_url = Url::fromRoute('view.uw_view_events.events_ical');
$ical_url->setOptions(['query' => $view->getExposedInput()]);
// Set the variable to the ical.
$view->ical = $ical_url->toString();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment