vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Need a Condition (https://vborg.vbsupport.ru/showthread.php?t=310957)

Forum-Germany 05-01-2014 07:56 PM

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>

kh99 05-01-2014 08:06 PM

You could try this:
Code:

<vb:if condition="($GLOBALS[counter]++ % 4) == 0"></vb:if>

Forum-Germany 05-01-2014 08:13 PM

Thanks!

My Forum with your Code.

Code:

<vb:if condition="($GLOBALS[counter]++ % 4) == 0">TEST</vb:if>
- Forum 1
-- 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

kh99 05-01-2014 08:44 PM

So you are getting every 2nd instead of every 4th? Hmm...

Forum-Germany 05-01-2014 08:51 PM

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?

kh99 05-01-2014 09:01 PM

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.

Forum-Germany 05-01-2014 09:01 PM

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:

- Forum 1
-- Sub-Forums TEST
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums TEST
-- Sub-Forums

- Forum 2
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums TEST
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums TEST
...
...
...
... TEST

- Forum 3
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums TEST
-- Sub-Forums
-- Sub-Forums
So I would like it.

Quote:

- Forum 1
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums TEST
-- Sub-Forums
-- Sub-Forums

- Forum 2
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums TEST
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums
... TEST
...
...
...

- Forum 3
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums
-- Sub-Forums TEST
-- Sub-Forums
-- Sub-Forums

vBNinja 05-01-2014 09:32 PM

what template did you put that code in?

Forum-Germany 05-01-2014 10:20 PM

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"

vBNinja 05-01-2014 10:40 PM

yea you're gonna need a plugin


All times are GMT. The time now is 07:21 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
  • Page Generation 0.01084 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete