MyBB Hacks

Full Version: Hide posts from guests {Show first post only]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is simple request to show only first post to guests and hide the remaining posts and an option to add a note after the first [custom insert] post to add something register to view replies, like so...

Can we make it with conditionals?
You could do a bit of a dirty trick with conditionals - stick around your postbit template:

HTML Code
<if $mybb->user['uid'] != 0 || $post['pid'] == $GLOBALS['thread']['firstpost'] then>
...
</if>


Also edit showthread, find both instances of:

HTML Code
    <div class="float_left">
        {$multipage}
    </div>

Replace with

HTML Code
    <if $mybb->user['uid'] != 0 then><div class="float_left">
        {$multipage}
    </div></if>

Finally, forumdisplay_thread, find:

HTML Code
{$thread['multipage']}

replace with

HTML Code
<if $mybb->user['uid'] != 0 then>{$thread['multipage']}</if>

marvellous zinga, its working. can i know how to add text below first post?
(11-15-2010 12:28 AM)1master1 Wrote: [ -> ]can i know how to add text below first post?

Using conditionals you have to add this in postbit template just below </table>
no problem, zinga. got it fixed. thank you for quick suggestion.
You can make this a quick plugin or editable plugin Smile
Yes, imran. It striked my mind just now Tongue. anyway thanks for the suggestion.
i think, we can do this way too. right?
instead of postbit edit you suggested, can we wrap the conditionals around {posts}
in

Code:
<div id="posts">
		{$first_post}{$posts}
	</div>

of "show thread" template

Try to stick around the complete postbit template as zinga wrote above;

PHP Code:
<if $mybb->user['uid'] != 0 || $post['pid'] == $GLOBALS['thread']['firstpost'] then>
...
</if>


there you see a $global variable which select the "first post" globally.

yep. you are right imran. i know zinga provided the best solution. but i just shared my view and i tried it on test board. lol. it gave a parse error.
{$first_post} requires XThreads.
I'm not sure if it's always set too, since it may decide to aggregate posts in {$posts} I think.
This works in normal view. Keep in mind, you can still reading all answers in archive mode. To fix this open archive/index.php
Find:

PHP Code:
// Finally show the post
			echo "<div class=\"post\">\n<div class=\"header\">\n<div class=\"author\"><h2>{$post['username']}</h2></div>";
			echo "<div class=\"dateline\">{$post['date']}</div>\n</div>\n<div class=\"message\">{$post['message']}</div>\n</div>\n";

replace with:

PHP Code:
			if ($mybb->user['uid'] == 0 && ($post['pid'] != $GLOBALS['thread']['firstpost'])) {
			echo "<div>Your Message to register or login.</div>";
			} else {

			// Finally show the post
			echo "<div class=\"post\">\n<div class=\"header\">\n<div class=\"author\"><h2>{$post['username']}</h2></div>";
			echo "<div class=\"dateline\">{$post['date']}</div>\n</div>\n<div class=\"message\">{$post['message']}</div>\n</div>\n";
			}


Dont know is there is a better solution. Unfortunately there are no templates for archive mode.

Pages: 1 2
Reference URL's