function views_get_view

Same name in other branches
  1. 7.x-3.x views.module \views_get_view()

Get a view from the database or from default views.

This function is just a static wrapper around views::load(). This function isn't called 'views_load()' primarily because it might get a view from the default views which aren't technically loaded from the database.

Parameters

$name: The name of the view.

$reset: If TRUE, reset this entry in the load cache.

Return value

view A reference to the $view object. Use $reset if you're sure you want a fresh one.

11 calls to views_get_view()
views_ajax in includes/ajax.inc
Menu callback to load a view via AJAX.
views_arg_load in ./views.module
Helper function for menu loading. This will automatically be called in order to 'load' a views argument; primarily it will be used to perform validation.
views_block in ./views.module
Implementation of hook_block
views_embed_view in ./views.module
Embed a view using a PHP snippet.
views_get_view_result in ./views.module
Get the result of a view.

... See full list

File

./views.module, line 1116

Code

function views_get_view($name, $reset = FALSE) {
    views_include('view');
    $view = view::load($name, $reset);
    $default_view = views_get_default_view($name, $reset);
    // The view does not exist.
    if (empty($view) && empty($default_view)) {
        return;
    }
    elseif (empty($view) && !empty($default_view)) {
        $status = variable_get('views_defaults', array());
        if (isset($status[$default_view->name])) {
            $default_view->disabled = $status[$default_view->name];
        }
        $default_view->type = t('Default');
        return $default_view->clone_view();
    }
    elseif (!empty($view) && !empty($default_view)) {
        $view->type = t('Overridden');
    }
    return $view->clone_view();
}