• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

Adding XenForo Thread Prefixes

Latest Community Threads Wide Prefix.png

XenForo thread prefixes were challenging to add to a widget. This is because a var_dump of the $prefixTitle was returning thread_prefix_.

Rich (BB code):
object(XenForo_Phrase)[255]
  protected '_phraseName' => string 'thread_prefix_1' (length=15)
  protected '_params' =>
   array (size=0)
     empty
  protected '_insertParamsEscaped' => boolean true
  protected '_phraseNameOnInvalid' => boolean true

It turns out the code was far easier than my initial twisted attempts.

PHP:
/** @var XenForo_Model_ThreadPrefix $prefixModel */
$prefixModel = XenForo_Model::create( 'XenForo_Model_ThreadPrefix' );
$thread_prefix = $prefixModel->getPrefixById($prefix_id);
$preparePrefix = $prefixModel->preparePrefix($thread_prefix);
$prefixTitle = $preparePrefix['title'];

echo $prefixTitle;

Next, an option to show prefixes needs to be added and the option added in the proper widgets.
  • Like
Reactions: robru

Blog entry information

Author
LPH
Views
2,079
Last update

More entries in Technology

More entries from LPH

Top