Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt November 11, 2024
Thomas P Posted March 6, 2018 Posted March 6, 2018 Hi folks, how can I put an advertisement within a post in a topic? I want to use an Ad Custom Location and it should show a rectangle within a post, next to the post text, i.e. on the right. Thanks for helping, Thomas
Thomas P Posted March 10, 2018 Author Posted March 10, 2018 Hi mates, a hint how to place a simple rectangle picture within a post would be very helpful Thanks in advance, Thomas
Nathan Explosion Posted March 10, 2018 Posted March 10, 2018 Start you off with a template hack.....edit the Forums -> Front -> Topics -> Post template, locate the following: {$comment->content()|raw} and replace it with: <div style="float:left"> {$comment->content()|raw} </div> <div style="float:right">TEST</div> That puts in all posts...there are several topics on here about how to display items in the first post only, or every x posts and all that. Give the divs a class, and then move the floats in to css and you can style away.
Thomas P Posted March 10, 2018 Author Posted March 10, 2018 Thanks Nathan, now I know where to start. I tried the following to no avail: <div style="float:left"> {$comment->content()|raw} </div> {{if $postCount == 1}} <div style="float:right">TEST</div> {{endif}} I doesn't show the "TEST"-part... I wonder why. Using this one -completely different logic- works though. <div style="float:left"> {$comment->content()|raw} </div> {{if !isset(request.page) or request.page == 1}} <div style="float:right">TEST</div> {{endif}} Is it because it isn't after the first post? ??
Thomas P Posted March 13, 2018 Author Posted March 13, 2018 Is there any documentation which variable are valid in which location? I guess I cannot use $postCount in the post-Template, since there is no result rendered... ?? I did not find it here, here or here. I found this promising add-on, but it is from 2011... Thank you for any helpful advice, Thomas
opentype Posted March 13, 2018 Posted March 13, 2018 8 minutes ago, Thomas P said: Is there any documentation which variable are valid in which location? There is a big “Variables …” button above the template editor window. It shows which variables are fed into the template you have opened.
Nathan Explosion Posted March 13, 2018 Posted March 13, 2018 Is $postCount a variable that you have created yourself? If so, then it will work depending on what you've passed as that variable ($postCount isn't a variable available by default, hence the question) But if you are trying to do "1st post only" then the answer is also in the template I guided you to.... {{if $comment->mapped('first') }} {{endif}}
Thomas P Posted March 13, 2018 Author Posted March 13, 2018 Thanks & Danke opentype. Thank you Nathan, that works - I didn't know what I should look for, I found $postCount in other templates and was on the wrong path. Honestly the code you mentioned wouldn't come in my mind. I owe you one ??
Thomas P Posted March 14, 2018 Author Posted March 14, 2018 Here is the working result: <!-- rectangle ad --> {{if $comment->mapped('first')}} <div style="float:right;margin-left:25px;margin-bottom:25px;">{advertisement="RectangleInPost"}</div> {$comment->content()|raw} {{else}} {$comment->content()|raw} {{endif}} <!-- // rectangle ad --> This works perfect and shows up in the first post in the upper right corner. Now I need to figure out how to show it in the 11, 21, 31st post in a topic ? Thanks, Thomas
mark007 Posted March 14, 2018 Posted March 14, 2018 I really would have a solution to show ad in the first post but after first paragraph. Because this is the optimal position....
Nathan Explosion Posted March 14, 2018 Posted March 14, 2018 8 hours ago, mark007 said: I really would have a solution to show ad in the first post but after first paragraph. Because this is the optimal position.... So inside the actual content itself?
mark007 Posted March 14, 2018 Posted March 14, 2018 1 hour ago, Nathan Explosion said: So inside the actual content itself? yes ...
Nathan Explosion Posted March 14, 2018 Posted March 14, 2018 3 hours ago, mark007 said: yes ... OK - that's achievable but the problem then is that it is part of the content - quoting a post will result in the advertisement being part of the quote. If I can figure out another way of achieving the addition of the ad to the content that avoids that side effect then I will put out a plugin and post it here.....no post from me = no plugin (yet)
mark007 Posted March 15, 2018 Posted March 15, 2018 7 hours ago, Nathan Explosion said: If I can figure out another way of achieving the addition of the ad to the content that avoids that side effect then I will put out a plugin and post it here This would be great ?
Thomas P Posted March 16, 2018 Author Posted March 16, 2018 On 3/14/2018 at 8:31 AM, Thomas P said: Now I need to figure out how to show it in the 11, 21, 31st post in a topic ? If someone has an idea to show content in the 11 and x post, I would be thankful. {{if $comment->mapped('first')}} I guess this is the part which should be modified, a pity that it isn't numeric...
Nathan Explosion Posted March 16, 2018 Posted March 16, 2018 {{$postCount =++$_REQUEST[ $item->tid . '_counter' ];}} {{if($postCount === 1 OR $postCount === 3 OR $postCount === 5)}} BLAH!!!! {{endif}}
Nathan Explosion Posted March 20, 2018 Posted March 20, 2018 On 15/03/2018 at 6:08 AM, mark007 said: This would be great ? See gif.....proof of concept done, moving on to some settings now.
mark007 Posted March 21, 2018 Posted March 21, 2018 By the way, I am really excited ?It ist very cool ... the optimal Adsense location
mark007 Posted March 25, 2018 Posted March 25, 2018 @Nathan Explosion This community has done that ... and it is so much better CTR and active view. ? (this is desktop view, but it is more significant when using a smartphone)
Nathan Explosion Posted March 25, 2018 Posted March 25, 2018 That's nice...why are you tagging me and letting me know though? On 14/03/2018 at 10:31 PM, Nathan Explosion said: no post from me = no plugin (yet) When it's ready, it will be released.
mark007 Posted March 25, 2018 Posted March 25, 2018 49 minutes ago, Nathan Explosion said: That's nice...why are you tagging me and letting me know though? No special intention, I just saw that and wanted to let you know, because I saw that you don't follow this topic ?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.