view() public static method

Since: 2.0
public static view ( string $view, array | null $data = null, boolean | integer | array $expires = false, string $cache_mode = 'cache' ) : boolean | mixed | null | string | void
$view string Path of the view file
$data array | null (optional) Data to pass on to the template
$expires boolean | integer | array (optional) Time in seconds for the cache to expire, if 0 no expiration.
$cache_mode string (optional) Decides the caching method to use for the view.
return boolean | mixed | null | string | void
Ejemplo n.º 1
0
/**
 * Include a file that's child/parent theme-aware, and can be cached into object cache or transients
 *
 * @see PodsView::view
 *
 * @param string $view Path of the file to be included, this is relative to the current theme
 * @param array|null $data (optional) Data to pass on to the template, using variable => value format
 * @param int|bool $expires (optional) Time in seconds for the cache to expire, if false caching is disabled.
 * @param string $cache_mode (optional) Specify the caching method to use for the view, available options include cache, transient, or site-transient
 * @param bool $return (optional) Whether to return the view or not, defaults to false and will echo it
 *
 * @return string|bool The view output
 *
 * @since 2.0
 * @link http://pods.io/docs/pods-view/
 */
function pods_view($view, $data = null, $expires = false, $cache_mode = 'cache', $return = false)
{
    require_once PODS_DIR . 'classes/PodsView.php';
    $view = PodsView::view($view, $data, $expires, $cache_mode);
    if ($return) {
        return $view;
    }
    echo $view;
}