Anatoliy
Well-known member
I fixed option names and changed a template modification as suggested. Thanks one more time @Kirby and @briansol !
So, back to my original question regarding finder (or should I actually call it regarding repository ?).
findStillLongTitles() is fine, but findTooLongTitles() doesn't do what I want.
I want it to fetch threads where "Page Full Title" (means "Thread title" + 3 + "Board title") > $this->options()->av_threadTitles_max.
How to do that?
So, back to my original question regarding finder (or should I actually call it regarding repository ?).
findStillLongTitles() is fine, but findTooLongTitles() doesn't do what I want.
I want it to fetch threads where "Page Full Title" (means "Thread title" + 3 + "Board title") > $this->options()->av_threadTitles_max.
How to do that?
Code:
public function findTooLongTitles()
{
$limit = $this->options()->av_threadTitles_max - strlen(\XF::options()->boardTitle);
if($limit < 0){$limit = 1;}
$finder = $this->finder('\XF:Thread');
$expression = $finder->expression('CHAR_LENGTH(%s)', 'title');
$finder
->setDefaultOrder('thread_id')
->where($expression, '>', $limit)
->where('discussion_state', 'visible')
->where('discussion_type', '!=', 'redirect');
return $finder;
}
public function findStillLongTitles()
{
$finder = $this->finder('\XF:Thread');
$expression = $finder->expression('CHAR_LENGTH(%s)', 'title');
$finder
->setDefaultOrder('thread_id')
->where($expression, '>', $this->options()->av_threadTitles_max)
->where('discussion_state', 'visible')
->where('discussion_type', '!=', 'redirect');
return $finder;
}