SvennD
July 25, 2015

phpBB 3.1 rank forum specific

Posted on July 25, 2015  •  1 minutes  • 211 words  •  Suggest Changes

While allot functions are available in phpBB assigning a rank that only shows on certain forum’s is not one of them.  So I want an expert group that only shows rank “expert” in forums that a user can choice (custom field). I don’t really care for symphony or phpBB’s code base, so this is just a quick and very, very dirty hack.

So I only care about viewtopic.php, my hack includes using custom fields, (pretty much abusing)

from line 2006+

if (!empty($cp_row['blockrow']))
{
  foreach ($cp_row['blockrow'] as $field_data)
  {
    $template->assign_block_vars('postrow.custom_fields', $field_data);

    if ($field_data['S_PROFILE_CONTACT'])
    {
      $template->assign_block_vars('postrow.contact', array(
        'ID'		=> $field_data['PROFILE_FIELD_IDENT'],
        'NAME'		=> $field_data['PROFILE_FIELD_NAME'],
        'U_CONTACT'	=> $field_data['PROFILE_FIELD_CONTACT'],
      ));
    }

I added

# hack 
# check if the value is equal to the current forum name
if ($field_data['PROFILE_FIELD_VALUE'] == $topic_data['forum_name'])
{
  $template->assign_block_vars('postrow.custom_expert', array('IS_EXPERT_HERE' => 1));
}
# end of hack

This will iterate all custom fields, and if one of them is the same as the forum name. (so the user decided to pick that name out the dropdown), it will give 1. In the template file you can just use this to check:

<!-- BEGIN custom_expert -->
<!-- IF not postrow.custom_expert.IS_EXPERT_HERE -->
no expert
<!-- ELSE -->
expert
<!-- ENDIF -->
<!-- END custom_expert -->

Quick, easy, dirty, not upgrade-able, but hell it works.

Support

If you enjoyed this website, consider buying me a Dr. Pepper

Buy me a Dr PepperBuy me a Dr Pepper