View Full Version : [HUH?] if not first post display within first post
Dr.CustUmz
05-09-2016, 06:51 PM
Im lost, cant get this one down.
So Im trying to do a tab thingy, and show posts that are not the first post in a tab.
<if condition="$post[postcount] != 1">
but to do this i had to wrap the postbit template in an if is first post condition
so how can I get this to un contradict itself =/
heres what i have POSTBIT
<if condition="$post[postcount] == 1">
POSTBIT TEMPLATE WOULD GO HERE?
<div id="content1">
<if condition="$post[postcount] != 1">
PUT POSTS NOT POST 1 IN DIV - POSTBIT TEMPLATE WOULD GO HERE AGAIN BUT CONTRADICTS ITSELF
</if>
</div>
<div id="content2">
more stuff to only show if post one
</div>
</if>
ive tried this in the showthread template too using something like
<div id="posts">$postbits
<if condition="$FIRSTPOSTID">
but that failed.
this has to be possible somehow =/ maybe im over thinking it
Are you sure $post['postcount'] can be used for that? I thought that stores the current postcount of the user.
greigeh
05-09-2016, 08:21 PM
Can you not use defined <else conditions /> to get where you want to be?
Dr.CustUmz
05-09-2016, 11:09 PM
Are you sure $post['postcount'] can be used for that? I thought that stores the current postcount of the user.
$post[postcount] is the post number in a thread, starting back at 1 for the first post of every thread.
my if condition is not wrong, i just need a way to un-contradict myself, so i can show posts not post
1 within a div, in post 1... i think thats right lol, confussing myself now
Can you not use defined <else conditions /> to get where you want to be?
ya could... see somewhere it would fit? lol.
hmmmm just an idea, tested - results 2 post down
<if condition="$post[postcount] == 1">
POSTBIT TEMPLATE HERE
<div id="content1">
</if>
<if condition="$post[postcount] != 1">
POSTBIT TEMPLATE AGAIN HERE
</if>
<if condition="$post[postcount] == 1">
</div>
<div id="content2">
more stuff to only show if post one
</div>
</if>
TheLastSuperman
05-09-2016, 11:26 PM
Perhaps use one of the examples shown here:
https://vborg.vbsupport.ru/showpost.php?p=2089159&postcount=2
Of course remove the vb:if and make it vB3 compliant.
Edit: Rough example IF max posts per page is set to 20 in admincp:
<if condition="$post['postcount'] % $vboptions['maxposts'] == 19">YOUR CODE HERE</if>
Maybe I misunderstood too? Maybe this will help :p
Dr.CustUmz
05-09-2016, 11:30 PM
ok, so that almost did it, but the page output is (relative to the example code I placed above)
POSTBIT TEMPLATE HERE
<div id="content1">
</div>
<div id="content2">
more stuff to only show if post one
</div>
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
so div content 1 is empty and comment display at the end...
POSTBIT TEMPLATE AGAIN HERE should be inside div content1 hmmm...... beats me =(
TheLastSuperman
05-09-2016, 11:34 PM
ok, so that almost did it, but the page output is (relative to the example code I placed above)
POSTBIT TEMPLATE HERE
<div id="content1">
</div>
<div id="content2">
more stuff to only show if post one
</div>
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
POSTBIT TEMPLATE AGAIN HERE
so div content 1 is empty and comment display at the end...
POSTBIT TEMPLATE AGAIN HERE should be inside div content1 hmmm...... beats me =(
Post us YOUR entire postbit template so we can see, perhaps we'll notice the issue right off the bat.
Dr.CustUmz
05-09-2016, 11:37 PM
Perhaps use one of the examples shown here:
https://vborg.vbsupport.ru/showpost.php?p=2089159&postcount=2
Of course remove the vb:if and make it vB3 compliant.
Edit: Rough example IF max posts per page is set to 20 in admincp:
<if condition="$post['postcount'] % $vboptions['maxposts'] == 19">YOUR CODE HERE</if>
Maybe I misunderstood too? Maybe this will help :p
I'm trying to display all comments that are not the first post, within the first post, not show something after a specific post... well kinda but not in the same sense lol
i guess i can spoil the addon and show you guys one sec ill include code
--------------- Added 1462844841 at 1462844841 ---------------
https://vborg.vbsupport.ru/external/2016/05/24.png
https://vborg.vbsupport.ru/external/2016/05/25.png
this would be the new postbit template: replace red text with def postbit code (just keeping it short)
<if condition="$post[postcount] == 1">
***PASTE POSTBIT TEMPLATE HERE***
<input id="tab1" type="radio" name="tabs" checked>
<label for="tab1">Comments</label>
<input id="tab2" type="radio" name="tabs">
<label for="tab2">Disqus</label>
<input id="tab3" type="radio" name="tabs">
<label for="tab3">Facebook</label>
<input id="tab4" type="radio" name="tabs">
<label for="tab4">Google+</label>
<section id="content1">
</if>
<if condition="$post[postcount] != 1">
***PASTE POSTBIT TEMPLATE HERE***
</if>
<if condition="$post[postcount] == 1">
</section>
<section id="content2">
2
</section>
<section id="content3">
3
</section>
<section id="content4">
4
</section>
</if>
what it returns in page *notice content1 is blank, then postbit repeats (those would be comments) at the end, i cut it cause it just keeps repeating for each comment.
<input id="tab4" type="radio" name="tabs">
<label for="tab4">Google+</label>
<section id="content1">
</section>
<section id="content2">
...
</section>
<section id="content3">
...
</section>
<section id="content4">
...
</section>
<!-- END TEMPLATE: postbit -->
</div>
<!-- BEGIN TEMPLATE: spacer_close -->
</div>
</div>
</div>
<!-- / close content container -->
<!-- END TEMPLATE: spacer_close -->
<!-- / post #5 -->
<!-- END TEMPLATE: postbit_wrapper --><!-- BEGIN TEMPLATE: ad_showthread_firstpost -->
<!-- END TEMPLATE: ad_showthread_firstpost --><!-- BEGIN TEMPLATE: postbit_wrapper -->
<!-- post #6 -->
<!-- BEGIN TEMPLATE: spacer_open -->
<!-- open content container -->
<div align="center">
<div class="page" style="width:980px; text-align:left">
<div style="padding:0px 25px 0px 25px" align="left">
<!-- END TEMPLATE: spacer_open -->
<div id="edit6" style="padding:0px 0px 6px 0px">
<!-- this is not the last post shown on the page -->
<!-- BEGIN TEMPLATE: postbit -->
LIVE: DEV ZONE (https://dev.dirtrif.com/vb3/showthread.php?t=2)
TheLastSuperman
05-10-2016, 12:38 AM
Mannnnnnnnnnn why'd you break my brain! This is so simple I think it's being over-complicated or perhaps some of your </if> positions are not correct... see this example:
<section id="content1">
</if>
<if condition="$post[postcount] != 1">
***PASTE POSTBIT TEMPLATE HERE***
</if>
<if condition="$post[postcount] == 1">
</section>
I think... hmm perhaps you pasted the code in the wrong location. It's almost like you have the != backwards maybe? I've been stuck in a similar position when working on a mod waaaay back in the day very similar to DJ's mod https://vborg.vbsupport.ru/showthread.php?t=184136
I'll have another look tomorrow, been coding my brains out today and now brain = pudding! This looks like a job for Tomorrow Man :cool:.
Dr.CustUmz
05-10-2016, 01:03 AM
thanks, yeah my head hurts trying to figure this out, i like the idea of seperating the comments from the social comments, but i have tried so many ways i cant figure this out for nothing lol
makes sense to me just cant seem to get it
<if condition="$post[postcount] == 1">
***PASTE POSTBIT TEMPLATE HERE*** SHOWS FIRST POST
<section id="content1">
</if>
<if condition="$post[postcount] != 1">
***PASTE POSTBIT TEMPLATE HERE*** ALL POSTS NOT POST 1 NEED TO BE INSIDE CONTENT1 DIV*** THIS IS NOT THE COREECT PLACEMENT
</if>
<if condition="$post[postcount] == 1">
MORE STUFF IF POST 1
</section>
TheLastSuperman
05-10-2016, 06:36 PM
Okay I came back to this today and BAM it hit me... you're using conditionals to call postbit content but there is no way for it to know... hmm how to explain "it doesn't know with you simply pasting the template code that it should show post 1 versus post 2+ in the areas you're pasting the code". So when you see the info being shown twice it's because you pasted the ****** Postbit template contents here ****** more than once and the conditional will not split a query or anything of that nature.
***PASTE POSTBIT TEMPLATE HERE*** ALL POSTS NOT POST 1 NEED TO BE INSIDE CONTENT1 DIV*** <-- will not work because the postbit template code is calling to show all posts (or XX amount per page depending on settings).
You won't be able to do this unless you do some custom queries and a plugin of some sort, it simply won't differentiate between them despite using conditionals until you do so in my opinion.
Dr.CustUmz
05-10-2016, 07:39 PM
makes sense to me :) think I may just go about it another way (put the comments tabs under the forum comments or something just to not get too tied up on this.
my thinking behind it was cause ive done 2 templates for postbit before
quick ugly example
<if post 1>
some awesome postbit style
</if>
COULD USE ELSE HERE
<if not post 1>
some simple postbit style
</if>
but yeah, thats not the same thing. So I'm liking the easiness of just throwing this below the quick reply or something lol.
PinkMilk
05-15-2016, 09:53 PM
$thread['firstpostid']
Dr.CustUmz
05-15-2016, 10:00 PM
$thread['firstpostid']
I played with that var when I was messing with all this trying to figure it out.
in what way were you thinking?
PinkMilk
05-15-2016, 10:10 PM
Its been a while since playing with vb but I believe $thread['firstpostid'] is/was used to swap postbits (first post differ from others, amongst other things) at least thats what I think I used it for so my thinking is:
<if condition == "$thread['firstpostid']">
Do something
<else />
Do something else
</if>
Dr.CustUmz
05-15-2016, 10:54 PM
that shows "Do something" on every post. like I said I played with alot of things that maybe could have worked, but never was able to come up with anything
PinkMilk
05-16-2016, 06:04 PM
Ok so did a little playing around and have come up with this kind of cheat solution to hide replies when other tabs are open using jquery...
Open postbit template and copy it to a text file and save it as you will need it later.
headinclude template:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script>
$(document).ready(function(){
$('ul.tabs li').click(function(){
var tab_id = $(this).attr('data-tab');
$('ul.tabs li').removeClass('current');
$('.tab-content').removeClass('current');
$(this).addClass('current');
$("#"+tab_id).addClass('current');
// hide replies if other tabs clicked
if($(this).index()) {
$(".repliez").hide();
} else {
$(".repliez").show();
}
});
}); // end
</script>
Additional CSS:
ul.tabs{
margin: 0px;
padding: 0px;
list-style: none;
}
ul.tabs li{
background: none;
color: #222;
display: inline-block;
padding: 10px 15px;
cursor: pointer;
}
.first {
height:0!important;
padding:0!important;
}
ul.tabs li.current{
background: #ededed;
color: #222;
}
.tab-content{
display: none;
background: #ededed;
padding: 15px;
}
.tab-content.current{
display: inherit;
}
Top of postbit template (original):
<if condition="$post[postcount] == 1">
End of postbit template (original) add:
<ul class="tabs">
<li class="tab-link current" data-tab="tab-1">Comments</li>
<li class="tab-link" data-tab="tab-2">Discus</li>
<li class="tab-link" data-tab="tab-3">Facebook</li>
<li class="tab-link" data-tab="tab-4">Google</li>
</ul>
<div id="tab-1" class="tab-content first current">
</div>
<div id="tab-2" class="tab-content">
Relevent content here.
</div>
<div id="tab-3" class="tab-content">
Relevent content here.
</div>
<div id="tab-4" class="tab-content">
Relevent content here.
</div>
<else />
Now go find the postbit template copy you made earlier and make thse edits to it...find:
$template_hook[postbit_start]
<table class="tborder"
and change to $template_hook[postbit_start]
<table class="tborder repliez"
Add </if>to the end of the copy to close the condition.
and finally copy this all over to the end of original postbit template.
So now you should have something like
if condition
pb template
tabs
else
pb template
/if
Its probably not ideal thats why I said cheat solution but it does what you want I think?!
Dr.CustUmz
05-16-2016, 07:51 PM
oh shoot, and i was going to leave it the sloppy way I had it lol, I dont believe this is a cheat solution this is pro status THE SOLUTION lol havent got to throw it together yet, dont want to get sidetracked from my embed plugin atm. But this looks solid and amazing =)
thank you!
(this was inspired from a wordpress plugin btw ;) )
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.