The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
In the newattachmentbit template, I want to give every upload a number.
In php, I would just use a variable and increment it for every uploaded attachment. How do I do this in a vbulletin template? --------------- Added [DATE]1284974502[/DATE] at [TIME]1284974502[/TIME] --------------- I realize this could be done easily by using an ordered list in the newattachmentbit template instead of those ancient tables. I just tried it out with the list. It has not the effect that I want, though. If I use a list and remove the first uploaded attachment in the list, the list gets renumbered. I want the numbers to remain the same after removing an image from the list. Because I sometimes get requests like "attachment 1,4,13,25 should be removed". If the pics get renumbered, it creates a mess. So I must use an incrementing variable to achieve this. |
#2
|
|||
|
|||
![]()
I saw this idea a while ago in a mod - you can use the side-effect of an if condition to increment a counter, like:
Code:
<if condition="++$foo"></if> $foo // foo is 1 <if condition="++$foo"></if> $foo // foo is 2 |
#3
|
|||
|
|||
![]()
Thanks for the info, kh99. That is very useful.
Is there also a way to initialize the variable first? Because the above is not strictly correct. It would probably fill my php errors log files pretty quickly. |
#4
|
|||
|
|||
![]()
Yeah, I think you can do:
Code:
<if condition="$foo = 1"></if> or maybe Code:
<if condition="($foo = 1) == 1"></if> (I haven't tried these) BTW, what's not strictly correct about the one above, just the fact that it's not initialized? If the problem is that it's not initlaized before it's used anywhere at all, then I guess the only thing you can do is initialize it in a plugin (or use some existing variable) |
#5
|
|||
|
|||
![]()
Good stuff, kh99. I'll try it out.
--------------- Added [DATE]1284994753[/DATE] at [TIME]1284994753[/TIME] --------------- I tried it out. Unfortunately, it shows the same behavior as the ordered list. When I remove one of the attachments, the others get renumbered. I would like the original numbers to stay the same. |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|