LPH
Well-known member
The following code loops through and gets all the prefix titles.
I don't like the nested loop and the final structure relies on dropdown select:
ForumA Title
-- Prefix1 Title
-- Prefix2 Title
ForumB Title
-- Prefix2 Title
-- Prefix4 Title
In other words, the forum is listed and the possible prefixes are listed below it.
Question 1
Is there a better way to grab the forum title then the possible prefixes for that forum? I saw a
Question 2
Is there a way to organize these in the same order requested in the XenForo panel?
Code:
/** @var \XF\Entity\Forum $node */
$nodes = \XF::app()->finder( 'XF:Forum' )->fetch();
foreach ( $nodes AS $node ) {
$prefix_cache = $node->prefix_cache;
foreach ( $prefix_cache AS $prefix_id ) {
$prefixTitle = \XF::app()->templater()->fn( 'prefix_title', [ 'thread', $prefix_id ] );
echo $prefixTitle . '<br />';
}
}
I don't like the nested loop and the final structure relies on dropdown select:
ForumA Title
-- Prefix1 Title
-- Prefix2 Title
ForumB Title
-- Prefix2 Title
-- Prefix4 Title
In other words, the forum is listed and the possible prefixes are listed below it.
Question 1
Is there a better way to grab the forum title then the possible prefixes for that forum? I saw a
getPrefixesGrouped
()Question 2
Is there a way to organize these in the same order requested in the XenForo panel?