vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   conditional ad after 5th, 15th post (https://vborg.vbsupport.ru/showthread.php?t=318181)

Dave-ahfb 04-09-2015 01:36 PM

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?

kh99 04-09-2015 04:08 PM

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 '%'.

Dave-ahfb 04-11-2015 11:49 AM

That works but not as hoped for.

Lets say I want it after every 10th post regardless of page or post per page count?

Sal Collaziano 09-24-2017 01:43 PM

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?

MarkFL 09-24-2017 02:32 PM

Quote:

Originally Posted by Sal Collaziano (Post 2590076)
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. :)

Sal Collaziano 09-24-2017 06:09 PM

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?

MarkFL 09-24-2017 06:17 PM

Quote:

Originally Posted by Sal Collaziano (Post 2590082)
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 (Post 2590082)
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?

Sal Collaziano 09-24-2017 06:22 PM

Quote:

Originally Posted by MarkFL (Post 2590083)
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...

MarkFL 09-24-2017 09:07 PM

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. :)

Sal Collaziano 09-25-2017 12:40 PM

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

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 (Post 2590086)
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. :)



All times are GMT. The time now is 09:59 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.01033 seconds
  • Memory Usage 1,750KB
  • 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
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (5)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