View Full Version : Need help with, if condition
DamasGate
08-31-2010, 10:37 PM
Hello,
In the postbit template.
I need to show code at the end of every user post but only once per page of thread.
Its like "show an user's signature only once per page hack"
How to do that ?
Thank you
Guest190829
09-01-2010, 09:49 PM
This is going to take a little more than a simple if conditional; you'll need to create some cache array that stores whether or not a specific user has displayed a signature already.
DamasGate
09-01-2010, 10:27 PM
Oh, i do not know how to do that.
Any one can help with this ?
Thank you
BirdOPrey5
09-02-2010, 02:23 AM
This is going to take a little more than a simple if conditional; you'll need to create some cache array that stores whether or not a specific user has displayed a signature already.
You know thought this too but how does this mod do it?
https://vborg.vbsupport.ru/showthread.php?t=139689
It's just template conditionals and manages to show the sig only once per page???
I read the code but can't figure it out- it doesn't even look like it should work.
DamasGate
09-02-2010, 01:34 PM
Explanation:
I install a hack, "show user last 5 threads above his signature".
If user has more than post on the same thread, Show only one time his last 5 threads above his signature.
Like this:
<if condition=" THIS IS THE FIRST USER REPLY ON THE THREAD
show user last 5 threads above his signature
<if condition=" THIS IS THE The second, third, or fourth REPLY ON THE THREAD
DO NOT show user last 5 threads above his signature
I hope that is Clare :(
Good find by BirdOfPrey, I wouldn't have thought to do that but it works because an assignment has a value and can be put in a conditional, so you can create an array like Danny mentioned without needing a plugin.
Modifying the mod that BirdOfPrey found, I think something like this should work:
<if condition="!$vboptions['shownlinks'][$post[userid]] AND $vboptions['shownlinks'][$post[userid]] = true">
// Show user's links
</if>
BirdOPrey5
09-02-2010, 03:07 PM
kh99 - could you walk be through the logic of this- I just don't get it :confused:
$post[userid] is just a number, right? so it's like
!$vboptions['shownlinks'][999] AND $vboptions['shownlinks'][999] = true
Maybe I'm not getting how $vboptions['shownlinks'] works?
DamasGate
09-02-2010, 03:28 PM
Good find by BirdOfPrey, I wouldn't have thought to do that but it works because an assignment has a value and can be put in a conditional, so you can create an array like Danny mentioned without needing a plugin.
Modifying the mod that BirdOfPrey found, I think something like this should work:
<if !$vboptions['shownlinks'][$post[userid]] AND $vboptions['shownlinks'][$post[userid]] = true">
// Show user's links
</if>
WOW, Thats work greatttttttttttttttt
But only one thing now
If the user did not have any threads its show empty links box.
Is there any way to hide the box when user did not have any threads ?
Like this:
<if condition="USER DID NOT HAVE ANY THREADS"
DO NOT SHOW ANYTHING
</if>
I really very appreciate your patience and cooperation.
Many many many Thanks
Is there any way to hide the box when user did not have any threads ?
Like this:
<if condition="USER DID NOT HAVE ANY THREADS"
DO NOT SHOW ANYTHING
</if>
What code are you using to show the links?
DamasGate
09-02-2010, 11:35 PM
Helo,
I use this code
<form method="POST">
<fieldset style="padding: 2">
<legend>
My Last 5 Threads
</legend>
<font face="tahoma" size="1">$favo
</font>
</fieldset>
</form>
Thanks for help
$post[userid] is just a number, right? so it's like
!$vboptions['shownlinks'][999] AND $vboptions['shownlinks'][999] = true
Maybe I'm not getting how $vboptions['shownlinks'] works?
'shownlinks' is just an arbitrary string, it could be anything as long as other code isn't trying to use the same variable. In fact you probably don't even need to use $vboptions. In any case, $vboptions['shownlinks'] is an array used to store whether or not a user's links have been shown. When the code starts generating the page, $vboptions['shownlinks'] doesn't exist so it works just like an array where every value is false, so the first time the code checks user 999 it will be false and !$vboptions['shownlinks'][999] will be true. The part after the AND assigns "true" to a user's slot in the array, and since an assignment has a value (the value being assigned), it will always be "true". So it doesn't affect the logic if the if statement, it just gets the assignment done.
Does that make any sense? I'm not so good with the explaining.
ETA: Oh, well...I just noticed that the above code was missing "condition=" because I messed up when editing. Maybe that's what was confusing. :D
--------------- Added 1283474565 at 1283474565 ---------------
Helo,
I use this code
So you know where "$favo" comes from? I don't know what that is.
You could try surrounding the above with:
<if condition="$favo">
</if>
BirdOPrey5
09-03-2010, 12:07 AM
'
Does that make any sense? I'm not so good with the explaining.
ETA: Oh, well...I just noticed that the above code was missing "condition=" because I messed up when editing. Maybe that's what was confusing. :D
I think I got it now, thanks!
You could try surrounding the above with:
<if condition="$favo">
</endif>
I think the last line is :"</if>" not "</endif>"
I think the last line is :"</if>" not "</endif>"
Heh...yeah, thanks.
DamasGate
09-03-2010, 11:17 AM
So you know where "$favo" comes from? I don't know what that is.
You could try surrounding the above with:
<if condition="$favo">
</if>
Its work very good.
You are great kh99, Thanks Million
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.