forked from pods-framework/pods
-
Notifications
You must be signed in to change notification settings - Fork 0
Pods_view()
bonsak edited this page Nov 22, 2012
·
3 revisions
#pods_view() Include a file that's child/parent theme-aware, and can be cached into object cache or transients. This acts much like get_template_part(), but uses the full file name.
function pods_view (
$view,
$data = null,
$expires = false,
$cache_mode = 'cache',
$return = false
)
###Parameters
Parameter | Type | Details |
---|---|---|
$view | string | Path of the file to be included, this is relative to the current theme |
$data | array or null | (optional) Data to pass on to the template, using variable => value format; To pass all currently scoped variables just use compact( array_keys( get_defined_vars() ) ), or use compact( array( 'any', 'variable', 'name' ) ) to pass just specific ones |
$expires | int or boolean | (optional) Time in seconds for the cache to expire, set to false to disable caching |
$cache_mode | string | (optional) Specify the caching method to use for the view, available options include cache, transient, or site-transient |
$return | boolean | (optional) Whether to return the view or not, defaults to false and will echo it |
###Returns
(string or boolean) The view output, false if the file was not found
Example
<?php
// Grab the sidebar and pass a variable to it,
// without having to set it global (messy)
$i_can_access_this = 'I can access this variable in sidebar.php, unlike when I use get_template_part()';
pods_view( 'sidebar.php', compact( array_keys( get_defined_vars() ) );
// Echo the rss-feed.php file and cache it
// for future use as a transient for 3600 seconds (60 minutes)
pods_view( 'rss-feed.php', null, 3600, 'transient' );
###Available Since Version
2.0+
###See Also