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;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s