Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Surendra.S Posted May 3, 2016 Posted May 3, 2016 Hi All, Please suggest how to insert an ADVERTISEMENT inside the first post of each topic ? Any plugin/code available ?
Hunter Lyons Posted May 18, 2016 Posted May 18, 2016 You can insert an advertisement after the first post of each topic. This would be through the ACP itself. System -> Promotion -> Advertisements and create a new ad. Then set the location to be there. PCHelpforumBE 1
PCHelpforumBE Posted May 18, 2016 Posted May 18, 2016 Just now, Lyonharted said: You can insert an advertisement after the first post of each topic. This would be through the ACP itself. System -> Promotion -> Advertisements and create a new ad. Then set the location to be there. Thanks Lyonharted, correct, however i want it Inside the post, not under, so i would need to define a custom one, any suggestion where i can add the {advertisement="KEY"} ? media 1
Gabriel Torres Posted May 26, 2016 Posted May 26, 2016 This new plugin should help you to accomplish that: PCHelpforumBE and BomAle 2
marklcfc Posted August 11, 2016 Posted August 11, 2016 Any way to do this without the mod above? Surely there is some code?
forumdev99 Posted October 19, 2016 Posted October 19, 2016 I found the location in the templates for where to put the ad code to appear inside of the post, I just need the if/then statement syntax to limit it to only appear in the first post, instead of all posts. Open this template: Forums > Front > Topics > post ..and put your code right after this tags: <div data-role='commentContent' itemprop='text' class='ipsType_normal ipsType_richText ipsContained' data-controller='core.front.core.lightboxedImages'> [your ad code here use style="float:right;"] Can anyone suggest the code I would use to limit this to display only in the first post? media and marklcfc 2
media Posted October 22, 2016 Posted October 22, 2016 On 10/19/2016 at 3:29 PM, forumdev99 said: I found the location in the templates for where to put the ad code to appear inside of the post, I just need the if/then statement syntax to limit it to only appear in the first post, instead of all posts. Open this template: Forums > Front > Topics > post ..and put your code right after this tags: <div data-role='commentContent' itemprop='text' class='ipsType_normal ipsType_richText ipsContained' data-controller='core.front.core.lightboxedImages'> [your ad code here use style="float:right;"] Can anyone suggest the code I would use to limit this to display only in the first post? Can you please populate an example code for an ad that I can see? Thanks
media Posted March 22, 2017 Posted March 22, 2017 On 10/19/2016 at 3:29 PM, forumdev99 said: Can anyone suggest the code I would use to limit this to display only in the first post? Can anyone help us with this question please (PLEASE)? Thanks
BomAle Posted March 22, 2017 Posted March 22, 2017 {{if $comment->isFirst()}} [your ad code here use style="float:right;"] {{endif}} media 1
media Posted March 22, 2017 Posted March 22, 2017 10 hours ago, BomAle said: {{if $comment->isFirst()}} [your ad code here use style="float:right;"] {{endif}} Thank you @BomAle It works, and would you please help us one more thing it shows first post but if a topic has 105 posts and my pagination is every 25 How can I make this little script shows if the $comment == 1, 26, 51, 76 and so on???? Thank you so much for your help...
media Posted October 30, 2017 Posted October 30, 2017 (edited) On 3/22/2017 at 8:03 AM, media said: Thank you @BomAle It works, and would you please help us one more thing it shows first post but if a topic has 105 posts and my pagination is every 25 How can I make this little script shows if the $comment == 1, 26, 51, 76 and so on???? Thank you so much for your help... Quote {{if $comment->isFirst()}} [your ad code here use style="float:right;"] {{endif}} Anyone? Edited October 30, 2017 by media forumdev99 1
Numbered Posted October 31, 2017 Posted October 31, 2017 I solve some other thing, but it can help you, as i think. In forums-front-topics-topic i create new variable inside foreach cycle. before {{$postCount++;}}: {{$page = (\IPS\Request::i()->page ? (\IPS\Request::i()->page - 1) * \IPS\Settings::i()->forums_posts_per_page : 0); }} {{$comment->position = $page + $postCount;}} this will add 'position' value to the comment object. it will move as a param to the forums-front-topics-post template. So inside post template you can get $comment->position value with values, contain number of current post from first page (23,24,25,26,27.. any). Your solution will be like {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} {$ads} {{endif}} Hope it help you media 1
media Posted October 31, 2017 Posted October 31, 2017 2 hours ago, Upgradeovec said: I solve some other thing, but it can help you, as i think. In forums-front-topics-topic i create new variable inside foreach cycle. before {{$postCount++;}}: {{$page = (\IPS\Request::i()->page ? (\IPS\Request::i()->page - 1) * \IPS\Settings::i()->forums_posts_per_page : 0); }} {{$comment->position = $page + $postCount;}} this will add 'position' value to the comment object. it will move as a param to the forums-front-topics-post template. So inside post template you can get $comment->position value with values, contain number of current post from first page (23,24,25,26,27.. any). Your solution will be like {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} {$ads} {{endif}} Hope it help you Thank you, but still to complicated for me. I tried to add this into template bit but did not work {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- responsive1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-0000000000000000" data-ad-slot="5827740529" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> {{endif}}
Numbered Posted November 1, 2017 Posted November 1, 2017 (edited) 12 hours ago, media said: Thank you, but still to complicated for me. I tried to add this into template bit but did not work {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- responsive1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-0000000000000000" data-ad-slot="5827740529" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> {{endif}} Yep. Because you need to define 'position' value in the parent 'forums-front-topics-topic' template. Just open it, find line with {{$postCount++;}} (it placed inside foreach cycle) and after that line paste that: {{$page = (\IPS\Request::i()->page ? (\IPS\Request::i()->page - 1) * \IPS\Settings::i()->forums_posts_per_page : 0); }} {{$comment->position = $page + $postCount;}} It will define 'position' variable to $comment object, which send to post template as argument. And after that your previous code will work. Now that is var not defined and condition is always false. Edited November 1, 2017 by Upgradeovec
media Posted November 1, 2017 Posted November 1, 2017 7 hours ago, Upgradeovec said: Yep. Because you need to define 'position' value in the parent 'forums-front-topics-topic' template. Just open it, find line with {{$postCount++;}} (it placed inside foreach cycle) and after that line paste that: {{$page = (\IPS\Request::i()->page ? (\IPS\Request::i()->page - 1) * \IPS\Settings::i()->forums_posts_per_page : 0); }} {{$comment->position = $page + $postCount;}} It will define 'position' variable to $comment object, which send to post template as argument. And after that your previous code will work. Now that is var not defined and condition is always false. Looks like it works, but not displaying ads, instead HTTP 400 error It’s not you, it’s this link (it appears to be broken) Try this Retype the web address Go back to the last page Search for the page
Numbered Posted November 1, 2017 Posted November 1, 2017 (edited) 2 minutes ago, media said: Looks like it works, but not displaying ads, instead HTTP 400 error It’s not you, it’s this link (it appears to be broken) Try this Retype the web address Go back to the last page Search for the page It may be some issue with ads code? Try to just show post number. {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} #{$comment->position} {{endif}} If that return valid value - than it's a code issue. May be it can't load from ajax response (for example, code wait for some document ready state for init some variables) Edited November 1, 2017 by Upgradeovec
media Posted November 1, 2017 Posted November 1, 2017 1 hour ago, Upgradeovec said: It may be some issue with ads code? Try to just show post number. {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} #{$comment->position} {{endif}} If that return valid value - than it's a code issue. May be it can't load from ajax response (for example, code wait for some document ready state for init some variables) has to be the code because I have thıs code and workıng just fine, but when I switch to your code I get that error message {{if $comment->isFirst()}} <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- responsive1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-00000000000" data-ad-slot="5827740529" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> {{endif}} You code shows up just fine but when it comes to displaying ad: there is the problem I get that error message.. Something to do with you code triggering some kind of condition to prevent Google ad to display
media Posted November 1, 2017 Posted November 1, 2017 @Upgradeovec I am so embarrassed man... When I paste the ad code here I took my adsense ID from the coe and when I copied from here and pasted back to my website, I forgot to put AdSense ID back on men... Anyway, it works like a charm... Thank you so much for your help... Would you please show me where exactly put the post number to show add in posts? {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- responsive1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-0000000000000000" data-ad-slot="5827740529" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> {{endif}} Would you please edit my code and show me where I need to put number like 1, 10, 20, 30, 40 etc.
Numbered Posted November 2, 2017 Posted November 2, 2017 14 hours ago, media said: @Upgradeovec I am so embarrassed man... When I paste the ad code here I took my adsense ID from the coe and when I copied from here and pasted back to my website, I forgot to put AdSense ID back on men... Anyway, it works like a charm... Thank you so much for your help... Glad to help 14 hours ago, media said: Would you please show me where exactly put the post number to show add in posts? {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- responsive1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-0000000000000000" data-ad-slot="5827740529" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> {{endif}} Would you please edit my code and show me where I need to put number like 1, 10, 20, 30, 40 etc. As i see below - all worked well? Isn't it? I didn't know google ads platform well. But i think it don't neet to get current post number (or not?). Anyway - this code just check your first condition - show something (ads) when current post is first post on this page (isn't it?). You can paste inside anything without show current post number. Or, you can call {$comment->position} anywhere inside post template for return that number (to html or js calling - doesn't matter). I think i don't understand you well (sorry for bad english). media 1
media Posted November 2, 2017 Posted November 2, 2017 (edited) 7 hours ago, Upgradeovec said: Glad to help As i see below - all worked well? Isn't it? I didn't know google ads platform well. But i think it don't neet to get current post number (or not?). Anyway - this code just check your first condition - show something (ads) when current post is first post on this page (isn't it?). You can paste inside anything without show current post number. Or, you can call {$comment->position} anywhere inside post template for return that number (to html or js calling - doesn't matter). I think i don't understand you well (sorry for bad english). My question is Can I check the condition of post number and display the ad in any post on posts page If I have 25 posts per page on post page: I would like to display the ad in first post, 5th post, 15th post and etc. Where should I set the condition check to check the post count # on that code Like if post number === 1, 6, 10 and etc. {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} Edited November 2, 2017 by media
Numbered Posted November 2, 2017 Posted November 2, 2017 (edited) 22 minutes ago, media said: My question is Can I check the condition of post number and display the ad in any post on posts page If I have 25 posts per page on post page: I would like to display the ad in first post, 5th post, 15th post and etc. Where should I set the condition check to check the post count # on that code Like if post number === 1, 6, 10 and etc. {{if (($comment->position - 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} Yes, you can . Just write your logic in that condition. As example: {{if (($comment->position - 1) % 5 === 0)}} // will show on 1, 6, 11, 16... every five post not depend on posts per page {{if (($comment->position) % 2 === 0)}} // will show on every second post: 2, 4, 6, 8, 10... {{if (true)}} // every post :D. perfect for money :) {{if (($comment->position + 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} // every last post on page (depends on number of posts per page setting) {{if (($comment->position - 1) % (\IPS\Settings::i()->forums_posts_per_page*2) === 0)}} // every fist post but only on 2, 4, 6.. pages write any condition what you want {{if (\IPS\Member::loggedIn()->member_id === 123)}} // show something only for specific toxic member :D <style>body { font-family: 'Comic Sans MS'; color: pink; }</style> {{endif}} Edited November 2, 2017 by Upgradeovec media 1
media Posted November 2, 2017 Posted November 2, 2017 50 minutes ago, Upgradeovec said: Yes, you can . Just write your logic in that condition. As example: {{if (($comment->position - 1) % 5 === 0)}} // will show on 1, 6, 11, 16... every five post not depend on posts per page {{if (($comment->position) % 2 === 0)}} // will show on every second post: 2, 4, 6, 8, 10... {{if (true)}} // every post :D. perfect for money :) {{if (($comment->position + 1) % \IPS\Settings::i()->forums_posts_per_page === 0)}} // every last post on page (depends on number of posts per page setting) {{if (($comment->position - 1) % (\IPS\Settings::i()->forums_posts_per_page*2) === 0)}} // every fist post but only on 2, 4, 6.. pages write any condition what you want {{if (\IPS\Member::loggedIn()->member_id === 123)}} // show something only for specific toxic member :D <style>body { font-family: 'Comic Sans MS'; color: pink; }</style> {{endif}} OMG, you become my hero man.... Thank you so much for the insight.... Thank you thank you thank you..... Numbered 1
Recommended Posts