Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 04-04-2013, 10:29 AM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to display counter of how many sections u can see in each category

Hi,

I have been playing around the following three files

forumdisplay.php
/includes/functions_forumlist.php
forum.php

I tried to find how many sections in each category I was able to find out how to display the overall numbers
of sections in each category and the problem it that despite the permissions as it shows like there is 16 sections this forum yet it for that user it should be 4 sections as I have hidden all the rest

What I have done is made a global variable at the top of
forumdisplay.php file

PHP Code:
global $numberinforums
and below the following

PHP Code:
$forumbits construct_forum_bit($foruminfo['forumid']); 
added the following for loop

PHP Code:
for(int k=0sizeof($foruminfo['childlist']); k++){
$numberinforums++;

it loops through sizeof($foruminfo['childlist']) which is does how many elements r there in the array of each forum

yet I want to wrap the loop with if statements
like following

PHP Code:
for(int k=0sizeof($foruminfo['childlist']); k++){
if(
the user can see this forum increase counter){
$numberinforums++;
}

then I use in the forumdisplay template the following

PHP Code:
{vb:raw numberinforums
and to display the counter in the FORUMHOME I applied almost the same code
apart from the loop statement instead this

PHP Code:
sizeof($foruminfo['childlist']) 
added the following in /includes/functions_forumlist.php

PHP Code:
sizeof($children
I would really appreciate any tip or help anybody would give it to me

to apply the each section permission on each counter

Looking forward to the awsome helpers

Many thanks in advance
Reply With Quote
  #2  
Old 04-05-2013, 01:34 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any help?

waiting....
Reply With Quote
  #3  
Old 04-05-2013, 02:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe something like:

Code:
foreach ($foruminfo['childlist'] AS $fid)
{
   $forumperms = fetch_permissions($fid);
   if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])
   {
      $numberinforums++;
   }
}
Reply With Quote
  #4  
Old 04-05-2013, 03:40 PM
Honourable Honourable is offline
 
Join Date: Oct 2010
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

I just found another way which don't know seems to me much easier but wondering if it makes load or its not proffissional than yours

here is what I have found

PHP Code:
$subforumsasda construct_subforum_bit($forumid);
for(
$k=0$k sizeof($subforumsasda); $k++){
$nberoffosinside++;

in functions_forumlist.php added the above which is for each forum i construct the subforum and count the size of the array and loop through which appears to be no need to the loop

as this sizeof($subforumsasda) will be more than enough to get the value the advantage of I thought that it does the permission calculation for you automatically

Many thanks KH for your help I would appreciate your point of view and suggestion on which code I should use

yours or mine?

Thank you again

--------------- Added [DATE]1365180367[/DATE] at [TIME]1365180367[/TIME] ---------------

More simple code I have found just to help someone might need it

just added this

PHP Code:
$nberoffosinside  sizeof(construct_subforum_bit($forumid)); 
it does return the value that I wanted and does the permissions evaluation and everything and return the number of forums you only see

--------------- Added [DATE]1365181457[/DATE] at [TIME]1365181457[/TIME] ---------------

Here is another explaination as I designed a style changed the way to display the forums as boxes filled next each other once there is no space it does down using css inline box

I had problem when there is for example 4 sub forums then

3 will fill up and then one will come down

in this way the style will look no nice so I found that in each space I add adsense advert to make more money also make the style look fine

I had a problem when there is 5 forums I need google adsense advert with small size
when there is 4 forums I need with big size as two boxes will be empty in 4

3 boxes like following

BOX BOX BOX

AND ONE BOX THEN ADVERT NEXT TO IT WITH BIG SIZE

BOX AD VE R T

AND OTHER CASE

BOX BOX BOX
BOX BOX ADS

SMALL ADVERT HERE

TO SOLVE THIS PROBLEM

I HAVE DONE THE FOLLOWING

PHP Code:
if( ((sizeof(construct_subforum_bit($forumid))) % 3) == ) {
$nberoffosinside  true;
} else if ( ((
sizeof(construct_subforum_bit($forumid))) % 3) == 2) {
$nberoffosinside  false;

using this variable nberoffosinside if it true display small advert
if it false display big advert and so on

I hope this could someone else looking for the solution

remember the code should be added in includes/functions_forumlist.php

where you can find the following
PHP Code:
// build the template for the current forum 
paste the code below and go to your templates

forumhome_forumbit_level1_nopost
forumhome_forumbit_level2_nopost

using the variable with this way

<vb:if condition="{vb:raw nberoffosinside} == true">
big advert
<vb:else />
small advert
</vb:if>

Good luck everyone

thanks for your help

--------------- Added [DATE]1365182584[/DATE] at [TIME]1365182584[/TIME] ---------------

More concisely to do what I have done here is the instruction

go to includes folder in your forum root then functions_forumlist.php

search for


PHP Code:
// build the template for the current forum 
add below it

PHP Code:
if( ((sizeof(construct_subforum_bit($forumid))) % 3) == ) {
$nberoffosinside  2;
} else if ( ((
sizeof(construct_subforum_bit($forumid))) % 3) == 2) {
$nberoffosinside  1;

to apply this on your templates need to register the nberoffosinside variable with following instructions

search for following

PHP Code:
$templater->register('forumid'$forumid); 
add below it

PHP Code:
$templater->register('nberoffosinside'$nberoffosinside); 
now go to your following templates

forumhome_forumbit_level1_nopost
forumhome_forumbit_level2_nopost

using this code you can display the big and small adverts accodingly

PHP Code:
<vb:if condition="$nberoffosinside == 2">big advert</vb:if>
<
vb:if condition="$nberoffosinside == 1">small advert</vb:if> 
this solution for the forumhome and you will need a solution for the forumdisplay to do so follow the next

open forumdisplay.php file in your main forum root

search for

PHP Code:
construct_forum_bit($foruminfo['forumid']) 
below it add the following

PHP Code:
if( ((sizeof(construct_subforum_bit($forumid))) % 3) == ) {
$numberinforums  2;
} else if ( ((
sizeof(construct_subforum_bit($forumid))) % 3) == 2) {
$numberinforums  1;

samething to use this $numberinforums variable in forumdisplay template you will need to register it using the following

search for

PHP Code:
$templater->register('forumid'$forumid); 
below it add

PHP Code:
$templater->register('numberinforums'$numberinforums); 
note dont forget to save your files with the alteration

now go to forumdisplay template using this if statement

PHP Code:
<vb:if condition="$numberinforums == 2">big advert</vb:if>
<
vb:if condition="$numberinforums == 1">small advert</vb:if> 
you can display the adverts accordingly

hope it got cleared now more

Good luck everyone again

please KH point if there is something I have done incorrectly

Many thanks
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:34 PM.


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.03386 seconds
  • Memory Usage 2,230KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (21)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete