Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2013, 12:03 PM
cellow cellow is offline
 
Join Date: Oct 2006
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $forumid variable in $Globals for postbit,forumdisplay,forumhome,headerinclude,navba r

Hi,

our forum get monthly new subforums. and at the moment we define where and to who we will show our ads (which are located in postbit_legacy, forumhome, forumdisplay, showthread, header, headerinclude, footer, navbar templates) by template conditionals.

but everytime a new subforum created we have to update the array $GLOBALS['forumid'] all conditionals with the new forumid.

1.
to save time, we are thinking of adding a "$show_ads_forumid_variable" to somewhere and use it the conditionals, so we dont need always to update all conditionals with the new forumid.

2.
we put in the forum-options (forum-manager) a field like "show ads (yes/no)", so all templates in this forum will not show the ads if no-> selected....

i will be happy, when somebody could help me with this issue out, i am also will to pay for it...

thank for you...
Reply With Quote
  #2  
Old 02-07-2013, 12:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could create a plugin using hook location parse_templates and code something like this:
Code:
global $show, $forumid;
if (isset($forumid) AND in_array($forumid, array(1, 2, 3)))
{
   $show['ads_forumid_variable'] = 1;
}

then change all your template conditions to be:

Code:
<if condition="$show['ads_forumid_variable']">

if you wanted to get fancy you could make the forum list a field in the settings, or you could even make it an option when creating a forum.
Reply With Quote
  #3  
Old 02-07-2013, 01:19 PM
cellow cellow is offline
 
Join Date: Oct 2006
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you Kevin.

a) work this plugin also with conditions in postbit_legacy template?
b) in forums with the forumid 1, 2, 3, the ad will shown or not shown, if i use <if condition="$show['ads_forumid_variable']"> in the postbit_legacy template
Reply With Quote
  #4  
Old 02-07-2013, 01:22 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cellow View Post
Thank you Kevin.

a) work this plugin also with conditions in postbit_legacy template?

I haven't tried it, but I thought it would. Are you asking because it doesn't work in postbit_legacy?



Quote:
b) in forums with the forumid 1, 2, 3, the ad will shown or not shown, if i use <if condition="$show['ads_forumid_variable']"> in the postbit_legacy template
It should show the ads in forumid 1, 2, 3.
Reply With Quote
  #5  
Old 02-07-2013, 01:26 PM
cellow cellow is offline
 
Join Date: Oct 2006
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ah ok, so if i wouldnt like to show, i should use

PHP Code:
global $show$forumid;
if (isset(
$forumid) AND !in_array($forumid, array(123)))
{
   
$show['ads_forumid_variable'] = 1;

so the ad will not shown in forumids 1,2,3 ....

curiously the ads also not shown in forumhome ... although i just give some forumids in the plugin...

postbit_legacy doesnt work
Reply With Quote
  #6  
Old 02-07-2013, 01:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think froumhome does not have an associated forumid, so if you want them to show in forumhome, maybe try this:

Code:
global $show, $forumid;
if (!isset($forumid) OR !in_array($forumid, array(1, 2, 3)))
{
   $show['ads_forumid_variable'] = 1;
}

I'm not sure why it wouldn't work in postbit_legacy. What did you have in that template before?
Reply With Quote
  #7  
Old 02-07-2013, 01:38 PM
cellow cellow is offline
 
Join Date: Oct 2006
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

my aim is the set the forumids in the plugin where i dont want to show the ads... so how my final plugin code should look like, if i use <if condition="$show['ads_forumid_variable']"></if> in the templates...


in postbit_legacy it worked before only if i used just 1 forumid like "$forumid != 3" but with arrays never worked for me ...
i tried:
$thread['forumid']
$GLOBALS['forumid']
$foruminfo['forumid']
$forum['forumid']

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

I think you should be able to use the same condition (checking $show[''ads_forumid_variable']) in all places, if the plugin code is correct. It seems like it should work even in postbit_legacy.

I tested this: using hook parse_templates and this code:

Code:
global $show, $forumid;
if (!isset($forumid) OR !in_array($forumid, array(1, 3, 4)))
{
   $show['ads_forumid_variable'] = 1;
}

Then in postbit_legacy template I have:

Code:
<if condition="$show['ads_forumid_variable']">
Show Ads!!!
</if>

and I find that the "Show Ads!" appears in forum 2 but not in others.
Reply With Quote
  #9  
Old 02-07-2013, 02:32 PM
cellow cellow is offline
 
Join Date: Oct 2006
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks kevin for ur support so far!

it works with all other templates beside postbit_legacy...

i have this condition:
<if condition="(($post[postcount] % $vboptions[maxposts] == 1)) AND ($show['member']) AND $show['ads_forumid_variable']">

usually it should show for members who are not visiting the forum (ids in plugin) in the first post an ad.
but it doesnt...

i allready disabled and flushed all caching stuff (xcache,etc..)

maybe there is a correlation within other plugins? i select "1" as "order" for your plugin ... but it doesnt help...

i used andreas, template modification system which hooks starts at "template_compile" ... maybe this makes the problem?

is there any other location where i can hook your plugin?
Reply With Quote
  #10  
Old 02-07-2013, 03:17 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've created this https://vborg.vbsupport.ru/showthread.php?t=286403 which may help, really simple and does the job (pretty much)
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 02:45 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.04099 seconds
  • Memory Usage 2,250KB
  • 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
  • (5)bbcode_code
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete