MyBB Community Forums

Full Version: Toggle Threaded - Linear
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
We have seen that every thread has an option at the bottom-left: "Subscribe to this thread" that automatically gets changed after thread subscription and displays as "Unsubscribe from this thread".

[Image: 39tQeAM.png]

Well its a nice feature. It displays the required option only as well as the subscription state of the thread with the user's account. But what about this:

[Image: Fy9y8g0.png]

It shows both the options every time viewing a thread no matter the thread view is 'Linear' or 'Threaded'.

Okay let's play with the codes a little to give the same functionality as the thread subscription option toggle to thread view also. Lets toggle it.

So, open the following template:

ACP > Templates & Styles > Templates > {theme_name} Templates > Show Thread Templates > showthread

and find this code line:

<script type="text/javascript" src="jscripts/thread.js?ver=1603"></script>

add just after that:

<style type="text/css">#mode_{$mybb->input['mode']} { display: none; }</style>

Now in the same template find this code chunk:

<a href="showthread.php?mode=threaded&amp;tid={$tid}&amp;pid={$pid}#pid{$pid}">{$lang->threaded}</a> | <a href="showthread.php?mode=linear&amp;tid={$tid}&amp;pid={$pid}#pid{$pid}">{$lang->linear}</a>

Replace with:

<a id="mode_threaded" href="showthread.php?mode=threaded&amp;tid={$tid}&amp;pid={$pid}#pid{$pid}">{$lang->threaded}</a><a id="mode_linear" href="showthread.php?mode=linear&amp;tid={$tid}&amp;pid={$pid}#pid{$pid}">{$lang->linear}</a>

Save the template. You are done.
Now you can toggle you thread view links just like your thread subscription links.

[Image: 5pHd0YV.png]

Happy coding Big Grin
So useful ...

Thanks effone Wink