Skip to content

Instantly share code, notes, and snippets.

@jkeck
Created November 10, 2011 22:02
Show Gist options
  • Save jkeck/1356385 to your computer and use it in GitHub Desktop.
Save jkeck/1356385 to your computer and use it in GitHub Desktop.
function migrate_views_panes(){
$views_panes = db_query("SELECT * FROM {panels_pane} WHERE type = 'views2'");
while($view_pane = db_fetch_object($views_panes)){
$config = unserialize($view_pane->configuration);
$view = views_get_view($view_pane->subtype);
$keys = array_keys($view->display["default"]->display_options["arguments"]);
$new_args = array();
foreach($keys as $i=>$key){
if($key != "group_nid"){
$new_args[$key] = $config["arguments"][$i];
}
}
$subtype = $view_pane->subtype . "-panel_pane_1";
if(isset($config["arguments"])){
$config["arguments"] = $new_args;
}
if(isset($config["nodes_per_page"])){
$config["items_per_page"] = $config["nodes_per_page"];
unset($config["nodes_per_page"]);
}
$record = array("pid" => $view_pane->pid, "type" => "views_panes", "configuration" => $config, "subtype" => $subtype);
drupal_write_record('panels_pane',$record,'pid');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment