forked from pods-framework/pods
-
Notifications
You must be signed in to change notification settings - Fork 0
Pods()
bonsak edited this page Nov 21, 2012
·
2 revisions
#pods()
function pods ( $type = null, $id = null, $strict = false )
###Parameters
Parameter | Type | Details |
---|---|---|
$type | string | The pod name |
$id | mixed | (optional) The ID or slug, to load a single record; Provide array of $params to run 'find' |
$strict | bool | (optional) If set to true, return false instead of an object if the Pod doesn't exist |
###Returns |
The Pods object
###Example
<?php
// Get the Pods object
$mypod = pods( 'mypod' );
// Get the Pods object for a specific item
$mypod = pods( 'mypod', $id_or_slug );
// Get the Pods object and run find()
$params = array(
'orderby' => 't.name DESC',
'limit' => 15,
'where' => 't.name != "Buster"'
);
$mypod = pods( 'mypod', $params );
// The above is the same as
$mypod = pods( 'mypod' )->find( $params );
// And the above is the same as
$mypod = pods( 'mypod' );
$mypod->find( $params );
// Check to see if an item was found or not
// at http://mysite.com/bunnies/voodoo-rabbit/
$slug = pods_var( 1, 'url' ); // get the second level of the current URL
$pods = pods( 'bunny', $slug );
if ( $pods->exists() ) {
// This bunny exists!
}
else {
// This bunny was not found, better send a 404.
// This only works if it's ran in a Pod Page Precode
// or if you set the $pods global to this before the
// theme runs, which is usually right after the
// 'after_setup_theme' action.
$pods = 404;
}
###Tutorials and other Resources
Semi-Protected Downloads with Transients, Cookies, and Pods Contributed by jchristopher An example of how to create a Downloads area on your site that is only accessible by members. URLs for direct downloads are protected and not easily passed around.
Building a Store Locator with proximity search using Pods Contributed by jchristopher Learn how to build a store locator with proximity search
Displaying Pods Items using Pods Pages & Pods Templates Contributed by Masino Sinaga How to use Pods Pages and Pods Templates with magic tags to show pods data.
###Available Since Version
2.0+
###Source File
pods() is located in /pods/functions.php
###See Also