mysite_render($type, $type_id, $uid = 0)
mysite.module, line 1171
Allows a MySite element to be used by an external application or menu callback
$type A string indicating the content type
$type_id The content id (such as term id) to retrieve
$uid The user account to retrieve MySite page settings for. Optional.
An array formatted according to mysite_type_hook_data on success or FALSE on failure.
function mysite_render($type, $type_id, $uid = 0) {
$types = variable_get('mysite_content', array());
if ($types[$type] == $type) {
// load the include and set the callback
mysite_load_includes('types', $type);
$func = 'mysite_type_'. $type .'_data';
// get the settings, if applicable
$settings = NULL;
$sql = "SELECT settings FROM {mysite_data} WHERE type = '%s' AND type_id = %d AND uid = %d";
$settings = db_result(db_query($sql, $type, $type_id, $uid));
if ($settings) {
$settings = unserialize($settings);
}
$data = $func($type_id, $settings);
}
else {
$data = FALSE;
watchdog('mysite', t('The requested content type %type is not available.', array('%type' => $type)));
}
return $data;
}