• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Filter threads by prefix menu

Mr Lucky

Well-known member
#1
Mr Lucky submitted a new resource:

Filter threads by prefix menu - Inspired by the Prefix Forum Listing addon

This will give you a prefix menu above the thread list which filters threads by prefix. (Much more obvious and intuitive than the existing Filter by prefix)

here's one I made earlier:

View attachment 161859

You can do this via a template modification or just customise the template itself.
  • Make a note of the prefix names and IDs (you can see the ID number in the URL of the main Thread Prefixes list - click on the prefix and note the number at the end. Alternatively click...
Read more about this resource...
 

DL6

Well-known member
#5
I suggest using this modification, it is only shown in the forums where prefixes are available and you do not have to edit it every time you add a new one.
Code:
<xf:if is="$forum.prefix_cache">
    <div style="margin-bottom:10px">
        <span class="">Filter by Prefix:</span>
        <a href="{{ link('canonical:forums', $forum, {'page': $page}) }}">
            <span class="label label--red">All</span>
        </a>
        <xf:foreach loop="$forum.prefix_cache" value="$PrefixId">
            <a class="labelLink" href="?prefix_id={$PrefixId}">
                <span class="label label--red">{{ prefix_title('thread', $PrefixId) }}</span>
            </a>
        </xf:foreach>
    </div>
</xf:if>
1511456784002.png
You can also display the original prefix style by replacing this:
Code:
<span class="label label--red">{{ prefix_title('thread', $PrefixId) }}</span>
For this:
Code:
{{ prefix('thread', $PrefixId, 'html', '') }}
1511457684968.png
 
Last edited:

ge66

Active member
#6
I suggest using this modification, it is only shown in the forums where prefixes are available and you do not have to edit it every time you add a new one.
Code:
<xf:if is="$forum.prefix_cache">
    <div style="margin-bottom:10px">
        <span class="">Filter by Prefix:</span>
        <a href="{{ link('canonical:forums', $forum, {'page': $page}) }}">
            <span class="label label--red">All</span>
        </a>
        <xf:foreach loop="$forum.prefix_cache" value="$PrefixId">
            <a class="labelLink" href="?prefix_id={$PrefixId}">
                <span class="label label--red">{{ prefix_title('thread', $PrefixId) }}</span>
            </a>
        </xf:foreach>
    </div>
</xf:if>
View attachment 162382
You can also display the original prefix style by replacing this:
Code:
<span class="label label--red">{{ prefix_title('thread', $PrefixId) }}</span>
For this:
Code:
{{ prefix('thread', $PrefixId, 'html', '') }}
View attachment 162383
Fantastic, thank you!
I made some small changes to fix the look of the all-link and to put in some phrases:
Code:
<xf:if is="$forum.prefix_cache">
    <div class="block">
        <span class="">{{ phrase('available_prefixes') }}:</span>
        <a href="{{ link('forums', $forum, {'page': $page}) }}" class="labelLink">
            <span class="label label--silver">{{ phrase('show_all') }}</span>
        </a>
        <xf:foreach loop="$forum.prefix_cache" value="$PrefixId">
            <a class="labelLink" href="?prefix_id={$PrefixId}">
                {{ prefix('thread', $PrefixId, 'html', '') }}
            </a>
        </xf:foreach>
    </div>
</xf:if>
 
#7
My links are going back to the forum index instead of filtering by prefix. What am I doing wrong here?

Code:
<div style="margin-bottom:10px">
<xf:if is="{$forum.node_id} == 76">
<span class="">Filter by Prefix:</span>
<a href="http://www.rolltidebama.com/forum/index.php?forums/fansights.76/">
<span class="label label--gray">All</span></a>
    <a class="labelLink" href="?prefix_id=15">
<span class="label label--gray">Football</span></a>
    <a class="labelLink" href="?prefix_id=19">
<span class="label label--gray">Basketball</span></a>
    <a class="labelLink" href="?prefix_id=20">
<span class="label label--gray">Recruiting</span></a>
    </xf:if>
</div>
 

Mr Lucky

Well-known member
#8
My links are going back to the forum index instead of filtering by prefix. What am I doing wrong here?

Code:
<div style="margin-bottom:10px">
<xf:if is="{$forum.node_id} == 76">
<span class="">Filter by Prefix:</span>
<a href="http://www.rolltidebama.com/forum/index.php?forums/fansights.76/">
<span class="label label--gray">All</span></a>
    <a class="labelLink" href="?prefix_id=15">
<span class="label label--gray">Football</span></a>
    <a class="labelLink" href="?prefix_id=19">
<span class="label label--gray">Basketball</span></a>
    <a class="labelLink" href="?prefix_id=20">
<span class="label label--gray">Recruiting</span></a>
    </xf:if>
</div>
It looks like you don't have friendly URLs enabled, maybe that is the issue.