Last active
August 29, 2015 14:16
-
-
Save airways/888cfea54e19ec2fcde1 to your computer and use it in GitHub Desktop.
Handle manager for ExpressionEngine - returning objects from an add-on
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Field: Returning an array or object as a variable, for instance in a fieldtype | |
ee()->load->library('handle_manager'); | |
$results = ee()->db->get('table_mapping')->results(); | |
$table_pattern = array( | |
"table_data" => ee()->handle_manager->register($results) // Returns a handle, e.x.: {&100} | |
); | |
ee()->TMPL->parse_variables($tagdata, array($table_pattern)); | |
{!-- Take the array of data in the table_data variable and pass it as a parameter to the plugin --} | |
{meta_table} | |
{exp:example:test region_mapping="{table_data}"} | |
{/meta_table} | |
// Plugin: Read a parameter | |
ee()->load->library('handle_manager'); | |
$p_region_mapping = ee()->handle_manager->fetch_param('region_mapping', array()); // Calls TMPL->fetch_param for us | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment