Resource icon

Filter threads by prefix menu

Mr Lucky

Well-known member
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...
 
You are great.

You do lot of help to peoples like me who does not understand coding.

Keep posting, thank you for all your works
 
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.webp
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.webp
 
Last edited:
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>
 
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>
 
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.
 
Hate to bump an old thread, but has anyone done this using a drop-down menu? I've got so manny prefixes (one for each state) that a drop-down menu would be the only way to do it.
 
Hate to bump an old thread, but has anyone done this using a drop-down menu? I've got so manny prefixes (one for each state) that a drop-down menu would be the only way to do it.
Very easy to do through the public navigation options.
 
Hate to bump an old thread, but has anyone done this using a drop-down menu? I've got so manny prefixes (one for each state) that a drop-down menu would be the only way to do it.

For many many links a select dropdown would be good.

I now have one in the header of my site see:


You can do this using the ad placement system, and simple select tag

EDIT: Maybe I should add this to the resource
 
pulling this out of the basement again but is there a way to make these buttons show up in the title bar instead of above it? See photo below for where I'm talking about.

1575668540156.webp
 
This was really great! Thanks.
But I want more... :)
Can I tweak it so a user can select multiple Prefixes?
 
Thanks for this!

PS. Would you be able to do this for labels/bookmarks so members could find their bookmarks easily by clicking a label at the top? Perhaps on the full page only.

Just a thought since the code might be similar.
 
Sorry, this is what it is. I'm not a developer - just sharing what I did as a workaround for xf2 while waiting for someone more competent than me to develpw an addon. I blieve by now there are some addons that will do this and more....
 
Top Bottom