![]() |
Need a Condition
Hello.
I need a IF-Condition to after every 4th forum (childforumbits) add HTML code. Example: - Forum 1 -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums ADD HTML-CODE -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums ADD HTML-CODE -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums ADD HTML-CODE - Forum 2 -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums ADD HTML-CODE -- Sub-Forums Thanks and best regards. PS: Maybe it will help? Code:
<vb:if condition="$GLOBALS[counter]++"></vb:if> |
You could try this:
Code:
<vb:if condition="($GLOBALS[counter]++ % 4) == 0"></vb:if> |
Thanks!
My Forum with your Code. Code:
<vb:if condition="($GLOBALS[counter]++ % 4) == 0">TEST</vb:if> -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums - Forum 2 -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST ... ... ... ... - Forum 3 -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST |
So you are getting every 2nd instead of every 4th? Hmm...
|
Yes!
If you would hide the categories, the word "TEST" in every second forum will be displayed. So yes, you're right. Can you help me? |
I suppose that you could try changing 4 to 8. Edit: But that won't work either, because the counter needs to be reset for every parent forum.
You really should use plugins to handle the counter. Sometimes you can cheat by using ++ in a condition, but it can be complicated to get it to work right. |
I have found a mistake. Sorry! :D
YES, now the word "TEST" appears in every 4th Forum. BUT ... The counter does not include the Forums Category. Now: Quote:
Quote:
|
what template did you put that code in?
|
Hello. :)
forumhome_forumbit_level2_post But does not matter. For it can not work 100% because the counter a) does not include the Forums category and b) the counter after the last sub-forum does not reset. An example: (Counter = 0) - Forum 1 -- Sub-Forums (Counter = 1) -- Sub-Forums (Counter = 2) -- Sub-Forums (Counter = 3) -- Sub-Forums (Counter = 4) ADD "TEST" -- Sub-Forums (Counter = 5) Counter Reset: (Counter = 0) - Forum 2 -- Sub-Forums (Counter = 1) -- Sub-Forums (Counter = 2) -- Sub-Forums (Counter = 3) -- Sub-Forums (Counter = 4) ADD "TEST" -- Sub-Forums (Counter = 5) -- Sub-Forums (Counter = 6) -- Sub-Forums (Counter = 7) -- Sub-Forums (Counter = 8) ADD "TEST" -- Sub-Forums (Counter = 9) Counter Reset: (Counter = 0) - Forum 3 -- Sub-Forums (Counter = 1) -- Sub-Forums (Counter = 2) -- Sub-Forums (Counter = 3) -- Sub-Forums (Counter = 4) ADD "TEST" Counter Reset: (Counter = 0) - Forum 4 -- Sub-Forums (Counter = 1) -- Sub-Forums (Counter = 2) Counter Reset: (Counter = 0) - Forum 5 -- Sub-Forums (Counter = 1) -- Sub-Forums (Counter = 2) -- Sub-Forums (Counter = 3) -- Sub-Forums (Counter = 4) ADD "TEST" -- Sub-Forums (Counter = 5) -- Sub-Forums (Counter = 6) -- Sub-Forums (Counter = 7) -- Sub-Forums (Counter = 8) ADD "TEST" |
yea you're gonna need a plugin
|
why not just put the ads in the description boxes of the forums?
|
Maybe something like this, a plugin using hook forumbit_display:
PHP Code:
Code:
<vb:if condition="$show['forumbit_ad']">TEST</vb:if> |
Thank you for F your efforts! :)
Unfortunately, it does not yet work properly. - Forum 1 -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST - Forum 2 -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums TEST - Forum 3 -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums TEST -- Sub-Forums -- Sub-Forums TEST |
Oh right, I think it should have been:
PHP Code:
|
It works. :up: But not in the first forum.
- Forum 1 -- Sub-Forums TEST :confused: -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums TEST -- Sub-Forums - Forum 2 -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums TEST :up: -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums TEST :up: -- Sub-Forums -- Sub-Forums -- Sub-Forums - Forum 3 -- Sub-Forums -- Sub-Forums -- Sub-Forums -- Sub-Forums TEST :up: -- Sub-Forums -- Sub-Forums |
Hmm...well, I guess I'm at the point where I'd have to try it myself. Maybe I'll get a chance tomorrow.
|
I thank you from the heart! :up:
|
OK, try this:
PHP Code:
|
It works! You are the man! ;)
Could you still extend the code on the last forum? So that's the last forum is detected? |
The last child? Maybe something like this:
PHP Code:
Code:
<vb:if condition="$show['last_child_forum']">LAST</vb:if> |
THANK YOU! :up: :up: :up:
--------------- Added [DATE]1399141625[/DATE] at [TIME]1399141625[/TIME] --------------- A change I would need yet. Hoping for your support. :) I would just need a condition that checks whether the last element is not the 4th item. example: A forum category has only 3 sub-forums. Text "LAST" to be displayed only when the last element is not the fourth. |
Hello. :)
I think you have not read my last post (because of double post). :o Can you tell me please still help with this one thing? :o If the last element (sub-board) is not the 4th, it is also to be "marked". |
Well, you have $show['forumbit_ad'] and $show['last_child_forum'], so you should be able to check both if you want. For example:
Code:
<vb:if condition="$show['last_child_forum'] AND !$show['forumbit_ad']">LAST</vb:if> |
THANK YOU! :up:
|
All times are GMT. The time now is 07:19 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|