Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Hide posts from guests {Show first post only]
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #1
Hide posts from guests {Show first post only]
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?
11-14-2010 04:24 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Hide posts from guests {Show first post only]
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>


My Blog
11-14-2010 07:48 AM
Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #3
RE: Hide posts from guests {Show first post only]
marvellous zinga, its working. can i know how to add text below first post?
11-15-2010 12:28 AM
Find all posts by this user Quote this message in a reply
Imran Offline
Member
***
Posts: 204
Joined: Apr 2010
Post: #4
RE: Hide posts from guests {Show first post only]
(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>

[Image: logo.png]

[Image: twitter.png]
11-15-2010 12:33 AM
Visit this user's website Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #5
RE: Hide posts from guests {Show first post only]
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.
(This post was last modified: 11-15-2010 12:40 AM by 1master1.)
11-15-2010 12:38 AM
Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #6
RE: Hide posts from guests {Show first post only]
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

11-15-2010 02:40 AM
Find all posts by this user Quote this message in a reply
Imran Offline
Member
***
Posts: 204
Joined: Apr 2010
Post: #7
RE: Hide posts from guests {Show first post only]
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.


[Image: logo.png]

[Image: twitter.png]
11-15-2010 03:24 AM
Visit this user's website Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #8
RE: Hide posts from guests {Show first post only]
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.
11-15-2010 03:44 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #9
RE: Hide posts from guests {Show first post only]
{$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.

My Blog
11-15-2010 07:49 AM
Find all posts by this user Quote this message in a reply
TriTop Offline
Member
***
Posts: 53
Joined: Apr 2008
Post: #10
RE: Hide posts from guests {Show first post only]
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:
1
2
3
4
5
6
7
8
			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.

11-20-2010 03:30 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: