Since: 1.10.6
pods_var
Return a variable (if exists)
pods_var is deprecated. Please use pods_v instead.
Function Definition
function pods_var ( $var = 'last', $type = 'get', $default = null, $allowed = null, $strict = false, $casting = false, $context = 'display' )
Source File: /pods/includes/data.php
Parameters
Parameter | Type | Details |
---|---|---|
$var | (mixed) | The variable name or URI segment position |
$type | (string) | (optional) get|url|post|request|server|session|cookie|constant|globals|user|option|site-option|transient|site-transient|cache|date|pods |
$default | (mixed) | (optional) The default value to set if variable doesn't exist |
$allowed | (mixed) | (optional) The value(s) allowed |
$strict | (bool) | (optional) Only allow values (must not be empty) |
$casting | (bool) | (optional) Whether to cast the value returned like provided in $default |
$context | (string) | (optional) All returned values are sanitized unless this is set to 'raw' |
Returns
(mixed) The variable (if exists), or default value
Examples
Use Pods Var To Get The Permalink
pods_var() can be very useful for retrieving the permalink or slug of an Advanced Content Type and using it to set the Pods object for a single item. This examples presumes that the "Detail Page URL" field under the "Advanced Options" tab in the Pods Editor is set to "pod_name/{@permalink}" or any other scheme where the permalink field is the final segment of the URL. Otherwise, you will need to specify the URL segment with an integer, starting from zero.
//get current item
$slug = pods_var( 'last', 'url' );
//get pods object for current item
$pods = pods( 'pod_name', $slug );