Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 04-09-2015, 01:36 PM
Dave-ahfb Dave-ahfb is offline
 
Join Date: Mar 2002
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default conditional ad after 5th, 15th post

I have it working fine after 5 posts with
[code]<vb:if condition="$post['postcount'] % $vboptions['maxposts'] == 5">;/code]

and it puts the 2nd ad under 15 if I change the 5 to 15.

It also places ads under 30 and so on (for those with extended posts per page)

Is there a way to combine the conditional statement to include the ad spots I want like 5, 15, 25, 35 rather than right a new conditional which seems to have less control?
Reply With Quote
  #2  
Old 04-09-2015, 04:08 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should be able to do this:
Code:
<vb:if condition="in_array($post['postcount'], array(5, 15, 25, 35))">
but then you have to list all positions instead of having them repeat due to the '%'.
Reply With Quote
  #3  
Old 04-11-2015, 11:49 AM
Dave-ahfb Dave-ahfb is offline
 
Join Date: Mar 2002
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That works but not as hoped for.

Lets say I want it after every 10th post regardless of page or post per page count?
Reply With Quote
  #4  
Old 09-24-2017, 01:43 PM
Sal Collaziano Sal Collaziano is offline
 
Join Date: Dec 2001
Location: Royal Palm Beach, Florida
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm curious about this also. I'd like to place an ad after the 3rd post on every page. Is there a solution to do this?
Reply With Quote
  #5  
Old 09-24-2017, 02:32 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Sal Collaziano View Post
I'm curious about this also. I'd like to place an ad after the 3rd post on every page. Is there a solution to do this?
Create a plugin hooked at "postbit_display_complete" with the following code:

PHP Code:
global $ids;

if (
$post['postid'] == $ids[2])
{
    
$template_hook['postbit_end'] .= 'Ad goes here...';

Replace 'Ad goes here...' with your ad HTML.
Reply With Quote
  #6  
Old 09-24-2017, 06:09 PM
Sal Collaziano Sal Collaziano is offline
 
Join Date: Dec 2001
Location: Royal Palm Beach, Florida
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you, Mark. Is there a way to get this to work with conditionals? I get:

syntax error, unexpected '<', expecting end of file on line 4 in /home/site/whatever/includes/class_postbit.php(345) : eval()'d code
#0 /home/buickfor/public_html/forums/showthread.php(1096): vB_Postbit->construct_postbit(Array)
#1 {main}

P.S. How was IRMA for you up there?
Reply With Quote
  #7  
Old 09-24-2017, 06:17 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Sal Collaziano View Post
Thank you, Mark. Is there a way to get this to work with conditionals? I get:

syntax error, unexpected '<', expecting end of file on line 4 in /home/site/whatever/includes/class_postbit.php(345) : eval()'d code
#0 /home/buickfor/public_html/forums/showthread.php(1096): vB_Postbit->construct_postbit(Array)
#1 {main}
What code did you use in your plugin?

Quote:
Originally Posted by Sal Collaziano View Post
P.S. How was IRMA for you up there?
We got a long of wind, but not a lot of rain in my neck of the woods. How did you guys fare?
Reply With Quote
  #8  
Old 09-24-2017, 06:22 PM
Sal Collaziano Sal Collaziano is offline
 
Join Date: Dec 2001
Location: Royal Palm Beach, Florida
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
What code did you use in your plugin?



We got a long of wind, but not a lot of rain in my neck of the woods. How did you guys fare?
I'm trying to use something like this:

<vb:if condition="!is_member_of($bbuserinfo, #,#,#)>
<li class="firstpost_advert_container">
<div class="firstpost_advert">
AD CODE HERE
</div>
</li>
</vb:if>

With Irma, we got a lot of strong wind. Lots of trees blown down. But very luckily, no flooding. None. That was great. I also never lost power. But lost internet for a few days...
Reply With Quote
  #9  
Old 09-24-2017, 09:07 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The conditional you are using is valid within a template only, however you can exclude usergroups within the plugin PHP code. For example:

PHP Code:
global $ids;

$excluded = array(567);

if (!
is_member_of($vbulletin->userinfo$excluded) AND $post['postid'] == $ids[2])
{
    
$template_hook['postbit_end'] .= 'Ad goes here...';

Make sure the HTML you add is within the single quotes...it needs to be a data string.

I prefer using plugins rather than hacking templates, if at all possible.
Reply With Quote
  #10  
Old 09-25-2017, 12:40 PM
Sal Collaziano Sal Collaziano is offline
 
Join Date: Dec 2001
Location: Royal Palm Beach, Florida
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is my first time using plugins, so please bear with me.

Here's what my plugin looks like now:

----- ----- -----
global $ids;

$excluded = array(199, 299, 399);

if (!is_member_of($vbulletin->userinfo, $excluded) AND $post['postid'] == $ids[2])
{
$template_hook['postbit_end'] .= '<li class="firstpost_advert_container"><div class="firstpost_advert">
<div class="firstpost_advert">
<center>
AD CODE HERE
</center>
</div>';
}
----- ----- -----

I'm still doing something wrong with my added code. What sticks out to you? I'm not in any of those user group IDs. Let me know what you think. Thank you very much!

Quote:
Originally Posted by MarkFL View Post
The conditional you are using is valid within a template only, however you can exclude usergroups within the plugin PHP code. For example:

PHP Code:
global $ids;

$excluded = array(567);

if (!
is_member_of($vbulletin->userinfo$excluded) AND $post['postid'] == $ids[2])
{
    
$template_hook['postbit_end'] .= 'Ad goes here...';

Make sure the HTML you add is within the single quotes...it needs to be a data string.

I prefer using plugins rather than hacking templates, if at all possible.
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 04:40 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05781 seconds
  • Memory Usage 2,267KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_php
  • (5)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_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