MyBB Hacks

Full Version: Thread Prefix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
With XThreads, we can create thread prefix. More than that, we can filter the threads based on their prefix.

Here is a simple way to do that:

1. Create a Custom Thread Fields with this settings:
  • Title: Prefix
  • Key: prefix
  • Applicable Forums: 'select a forum that we want the prefix to be applied'
  • Input Field Type: Listbox
  • Field Input Height: 1
    If we want multi prefix for a single thread, fill the Field Input Height with a value that greater than 1.
  • Values List:

    Code:
    Prefix 1
    Prefix 2
    Prefix 3

    Name it as our need.

  • Editable by / Required Field?: Everyone (Required)
  • Allow Filtering: Yes
  • Display Format:

    Code:
    [{VALUE}]

    If we want multi prefix, this will be the "main" display format.

  • Allow multiple values for this field: No
    If we want multi prefix for a single threads, choose Yes
  • Multiple Value Delimiter:

    Code:
    , 

    The Multiple Value Delimiter setting will be displayed if we choose Yes in Allow multiple values for this field setting. This is separator for each prefix.

  • Display Item Format:

    Code:
    {VALUE}

    The Display Item Format setting will be displayed if we choose Yes in Allow multiple values for this field setting. This is the display format for each prefix.

  • Formatting Map List:

    Code:
    Prefix 1{|}<a href="{$forumurl?}filtertf_prefix=Prefix 1"><span style="color: red;">Prefix 1</span></a>
    Prefix 2{|}<a href="{$forumurl?}filtertf_prefix=Prefix 2"><span style="color: green;">Prefix 2</span></a>
    Prefix 3{|}<a href="{$forumurl?}filtertf_prefix=Prefix 3"><span style="color: blue;">Prefix 3</span></a>


2. We need to edit our forumdisplay_thread template. The basic concept for this edit process is, adding {$GLOBALS['threadfields']['prefix']} variable into the forumdisplay_thread template. The prefix will be displayed wherever we put the variable in the template.

In this example, we will put the prefix before Thread Subject:
We can find this code in our forumdisplay_thread template (based on the default template):

HTML Code
<span>{$prefix} {$gotounread}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span>


Then, add the {$GLOBALS['threadfields']['prefix']} variable. So, the code will be like this:

HTML Code
{$GLOBALS['threadfields']['prefix']} <span>{$prefix} {$gotounread}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span>



Additional info:

  • The filtering url has a general structure:
    Quote:{$forumurl?}filtertf_Key_for_the_field=Name of each prefix
    In the example above:
    Key_for_the_field = prefix
    Name of each prefix = Prefix1, Prefix 2, and Prefix 3.

    So, the filtering URL will be like this:
    Quote:{$forumurl?}filtertf_prefix=Prefix 1
    {$forumurl?}filtertf_prefix=Prefix 2
    {$forumurl?}filtertf_prefix=Prefix 3
  • We can do some experiment with these three settings if we want multi prefix: Display Format, Multiple Value Delimiter and Display Item Format.

    Example 1:
    Display Format = [{VALUE}]
    Multiple Value Delimiter = , (plus one space)
    Display Item Format = {VALUE}
    Result:
    Quote:[Prefix 1, Prefix 2, Prefix 3] Thread Title

    Example 2:
    Display Format = {VALUE}
    Multiple Value Delimiter = one space
    Display Item Format = [{VALUE}]
    Result:
    Quote:[Prefix 1] [Prefix 2] [Prefix 3] Thread Title

    Example 3:
    Display Format = {VALUE}
    Multiple Value Delimiter = one space|one space
    Display Item Format = {VALUE}
    Result:
    Quote:Prefix 1 | Prefix 2 | Prefix 3 Thread Title
  • We can use image for the output of each prefix.
    Display Format = {VALUE}
    Multiple Value Delimiter = one space
    Display Item Format = {VALUE}
    Formatting Map List:

    Code:
    Prefix 1{|}<a href="{$forumurl?}filtertf_prefix=Prefix 1"><img src="image_url_for_prefix_1" alt="Prefix 1" title="Display Prefix 1 Only" /></a>
    Prefix 2{|}<a href="{$forumurl?}filtertf_prefix=Prefix 2"><img src="image_url_for_prefix_2" alt="Prefix 2" title="Display Prefix 2 Only" /></a>
    Prefix 3{|}<a href="{$forumurl?}filtertf_prefix=Prefix 3"><img src="image_url_for_prefix_3" alt="Prefix 3" title="Display Prefix 3 Only" /></a>

  • We can use the Prefix Filtering system as category for our XThreads application.
Wow, you pretty much got exactly what I did Rateu.

Personally, I don't set a template prefixes for the forum - I edit the original template directly.  Reason being is that if you disable prefixes for a certain forum, it won't show even if the variable is in the template anyway.  But your method does have more flexibility Smile

Thanks for the wonderful guide.
Ah, yes. I think editing the original template is more effective. Thanks, Yumi.
Hello, I speak Spanish and do not understand this line: S
1. Create a Custom Thread Fields with this settings:
Where I have to go?
, me explain more carefully to understand and make the tutorial?

Thanks
(08-20-2010 12:03 AM)Gypaete Wrote: [ -> ]Hello, I speak Spanish and do not understand this line: S
1. Create a Custom Thread Fields with this settings:
Where I have to go?
, me explain more carefully to understand and make the tutorial?

Thanks

Here is screenshots for that:

1. Please make sure that we have installed XThreads.
In our Admin CP, click Configuration tab (1).
We will see there is a side menu Custom Thread Fields there (2)
[attachment=165]

2. Click the Custom Thread Fields side menu. We will see this page (assuming that we didn't have a Custom Thread Fields yet):
[attachment=166]
Then, click Add Thread Field tab (3).

3. Now, we will see this page:
[attachment=167]
In that page we can set a Custom Thread Fields settings.
If we already set the  Custom Thread Fields settings, click Add Thread Field button at the bottom of the page.

If there is any question, please feel free to ask Smile

Thanks.
Allows you to MyBB 1.6?
Thank!
My ACP
[Image: prefix.jpg]
your ACP
[Image: attachment.php?aid=167] ?¿
Yep. XThreads is compatible with MyBB 1.6
aa Oks, downloading, if I have some more error, it said: D
There is an error, I installed, and I get this S:
Warning [2] require (/ mnt/web7/62/61/52431161/htdocs/foro/admin/modules/config/threadfields.php) [function.require]: failed to open stream: No such file or directory - Line: 483 - File: PHP admin/index.php 05/02/1912 (SunOS)
File Line Function
/ admin/index.php 483 errorHandler-> error
/ admin/index.php require 483

Fatal error: require () [function.require]: Failed opening required '/ mnt/web7/62/61/52431161/htdocs/foro/1995/modules/config/threadfields.php' (include_path ='.:/ opt / RZphp5/includes') in / mnt/web7/62/61/52431161/htdocs/foro/admin/index.php on line 483
Please make sure that you have threadfields.php file uploaded to your /admin/modules/config/ folder.
If I have: S
Pages: 1 2 3 4 5 6
Reference URL's