In a private module, I have code that allows custom field data to be included in “type_list” pages. For example:
// Make custom field data to include in item lists.
public function onManagerFormatResults($handler, $results) { // modifies manager results
global $_LW;
if ($_LW->page=='news' && $_SESSION['livewhale']['manage']['gid']==94) { // if on the news manager and in the magazine group
foreach($results as $key=>$val) { // get custom fields for each news result
if ($fields=$_LW->getCustomFields('news', $val['id'])) {
foreach($fields as $key2=>$val2) { // and add the values to the result
if (!isset($results[$key][$key2])) {
$results[$key][$key2]=$val2;
};
};
};
};
};
return $results;
}
// Append custom fields to item list output.
public function onManagerFormat($handler, $format) { // modifies manager formats
global $_LW;
if ($_LW->page=='news' && $_SESSION['livewhale']['manage']['gid']==94) { // if on the news manager and in the magazine group
$format=str_replace('</fieldset>', '{<div class="magazine_issue" style="text-align:right;"><strong>Issue:</strong> |magazine_issue|</div>}</fieldset>', $format); // add magazine_issue to the manager result format
};
return $format;
}
Result:
I’ve been trying to do the same with profiles, but nothing I do results in a custom field being shown.
Through testing, I found my attempt to use getCustomFields
for profiles…
$fields=$_LW->getCustomFields('profiles', $val['id'])
…comes back empty, and thus we don’t get past the if
that it is a condition for.
I assume this function is for settings-defined custom fields, like magazine_issue
above in news, and doesn’t include the custom fields defined in a profile type, like profiles_362
.
How might I make profile-defined custom fields (profiles_362
) available in a similar manner? I’m anticipating a dbo->query
to a specific table, or similar, but I’m also hoping for something as simple as getCustomFields
.
Thanks,
Nick