ElkArte Community

Title: hook integrate_messageindex_topics / Usage
Post by: Nifty on February 01, 2016, 12:43:30 pm
Hey,
seems that i am to stupid.
I try to use the "integrate_messageindex_topics" hook and insert a Field  which i like to retrieve from elkarte_threads as well
My Code for the handler ( which gets called)
Code: [Select]
class Topic_Prefix_Integrate
{
public static function integrate_messageindex_topics($optionArray){
//&$sort_column=$optionArray[0];
$indexOptions=$optionArray[1];

$indexOptions['custom_selects'] = array('t.prefix');
}
}

But it does not work out - Error Message:
Warning: Illegal string offset 'custom_selects' in /var/www/html/elk/sources/TopicPrefix.integrate.php on line 9

Notice: Array to string conversion in /var/www/html/elk/sources/TopicPrefix.integrate.php on line 9
Skip to main content

What is wrong here ?
Thanks
Title: Re: hook integrate_messageindex_topics / Usage
Post by: emanuele on February 01, 2016, 03:33:13 pm
Code: [Select]
class Topic_Prefix_Integrate
{
public static function integrate_messageindex_topics(&$sort_column, &$optionArray){
$optionArray['custom_selects'] = array('t.prefix');
}
}
$optionArray is passed as second argument of the function. ;)
Title: Re: hook integrate_messageindex_topics / Usage
Post by: Nifty on February 01, 2016, 03:48:43 pm
Many thanks.
Title: Re: hook integrate_messageindex_topics / Usage
Post by: emanuele on February 01, 2016, 05:46:45 pm
Oh, I didn't notice!
It would be much better to use:
Code: [Select]
if (empty($optionArray['custom_selects']))
    $optionArray['custom_selects'] = array();

$optionArray['custom_selects'][] = 't.prefix';
This way if the custom_selects is already defined by another addon it's not replaced entirely. ;)