Get view block by view name

This is a simple function to grab a View block by view name.

Usage:

my_get_view_block("my_view_name");

Code:

function my_get_view_block($viewname = NULL){
if(!empty($viewname)){
# from View name, i got the view ID
$vid = db_result(db_query('SELECT vid FROM {view_view} WHERE name = "%s"',$viewname));
# read related comments for views_view_block on view.module
$block = views_view_block($vid);
return $block;
}
else
return FALSE;
}