Skip to content

Instantly share code, notes, and snippets.

@m7v
Created March 28, 2014 01:03
Show Gist options
  • Save m7v/9822817 to your computer and use it in GitHub Desktop.
Save m7v/9822817 to your computer and use it in GitHub Desktop.
Views takes $_GET. {Hack} //Creating Ctools plugin that is retrieve views result by GET-parameters.
<?php
/**
* Callback function to supply a list of content types.
*/
function spaint_site_changelog_ctools_content_types() {
return array(
'single' => TRUE,
'title' => t('Changelog'),
'description' => t('Changelog CTools CT'),
'category' => t('spaint_site'),
'all contexts' => TRUE,
'defaults' => array('mode' => 'full'),
);
}
/**
* Output function for the content type
*/
function spaint_site_changelog_content_type_render($subtype, $conf, $panel_args, $contexts) {
$block = new stdClass();
$platforms = taxonomy_get_tree(SPAINT_SITE_PLATFORM_VOCABULARY);
$versions = taxonomy_get_tree(SPAINT_SITE_PLATFORM_VOCABULARY);
$view = views_get_view('changelog');
foreach ($platforms as $platform) {
if ($platform->name == $_GET['os']) {
$os = $platform->tid;
}
}
foreach ($versions as $version) {
if ($version->name == $_GET['version']) {
$v = $version->tid;
}
}
$output = $view->preview('master', array($os, $v));
$block->content = $output;
return $block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment