Digital Point Ad Positioning

Digital Point Ad Positioning 1.3.0b

No permission to download
If there are no unread posts, it will revert to the first post in the thread. The whole point of the ad IN the post is so that it's in the post you are currently reading (or at least it's best guess which one that would be).
 
Sometimes I click on a thread I never read before and I am redirected to the newest post (lets say the last post of the eight posts of the thread). But the ad is placed in the first post of the page.

1. from forum_list you click on the latest thread. http://domain.com/posts/12345

2. posts/12345 redirects to threads/23483/#post-12345
Browser is navigating to this post

3. $this->_params['unreadLink'] is set to the first post (let's say it is #post-12000).
Ad is displaying at the first post which is not within the first browser view at all

Any ideas how to solve that as easy as possible?
 
This is a nice add on but there're plenty of threads where I had errors and could not access them. similar to Russ bug
 
Sometimes I click on a thread I never read before and I am redirected to the newest post (lets say the last post of the eight posts of the thread). But the ad is placed in the first post of the page.

1. from forum_list you click on the latest thread. http://domain.com/posts/12345

2. posts/12345 redirects to threads/23483/#post-12345
Browser is navigating to this post

3. $this->_params['unreadLink'] is set to the first post (let's say it is #post-12000).
Ad is displaying at the first post which is not within the first browser view at all

Any ideas how to solve that as easy as possible?
Since it's based on the unread link, if the unread link is set to #post-12000, and post ID 12000 exists on the page, I can't think of any way at all that the ad wouldn't be attached to that post. Are you 100% certain that Post ID 12000 is on the page you are looking at?

This is a nice add on but there're plenty of threads where I had errors and could not access them. similar to Russ bug
Yeah, I'm not sure why the addon he was using was causing it, but ultimately when it comes down to it, if you have a BBCode addon that is doing something weird with the "magic method" __ToString() for itself, it would cause problems.
 
I ended up disabling the built in ones to that add-on and the problem went away.

On a side note DP, can we use conditionals inside the ad code at all? Show to a certain group/exclude certain forums
 
The unread link always points to the first unread post *on the actual page*.

So if on forum list you click on the latest /post/ link, you will be redirected to the thread with this post as anchor.

If you have never seen this thread the unread post is always the first post on this page.
 
I ended up disabling the built in ones to that add-on and the problem went away.

On a side note DP, can we use conditionals inside the ad code at all? Show to a certain group/exclude certain forums
There are some settings on the options page that gives you some control over usergroups and forums to display ads in already... As far as making the ad HTML have some freeform logic, it's probably not going to be possible since it's HTML and not BBCode. If you make it all BBCode, then you would lose the ability to do things like include JavaScript (important for most ad serving).

The unread link always points to the first unread post *on the actual page*.

So if on forum list you click on the latest /post/ link, you will be redirected to the thread with this post as anchor.

If you have never seen this thread the unread post is always the first post on this page.
Right, and isn't that what you would want? If you haven't read *any* of the posts on the page, the ad being on the first post on that page?
 
The ad appears at the first unread post which may be post 10.

However on forum list there are only links to the LATEST posts.

As an example you click on posts/24 and you will be redirected to thread/xxx/#post-24. The ad wil be in post 10.
 
Ya I'm aware of those, it's just a tad bit limited for what I need to be done. I need to hide the ads in a certain forum to anyone, currently it's the opposite where it only allows you to force things or hide to certain groups.
 
Its not this products fault. One would have to either change xfs behavior by js or with a template edit for the node templates.
 
The ad appears at the first unread post which may be post 10.

However on forum list there are only links to the LATEST posts.

As an example you click on posts/24 and you will be redirected to thread/xxx/#post-24. The ad wil be in post 10.
Yeah, but not sure there's a lot that can be done about that... if they are on a page (for whatever reason) that doesn't contain the first unread post for them, it will simply fall back to the first post on the page. It's an unfortunate side effect of the hash part of a URL being client-side only (the server-side does not know the the user is at #post-12345 for example). So I'm using the best thing that I could find that *is* server-side (the unread link) to make an educated guess of what the user is looking at. It's most certainly not perfect, and I really wish there was a way to be able to read the hash part of a URL on the server-side. But since it's not possible, we are left with other options for determining what they are looking at.

Ya I'm aware of those, it's just a tad bit limited for what I need to be done. I need to hide the ads in a certain forum to anyone, currently it's the opposite where it only allows you to force things or hide to certain groups.
Not sure it would be possible without making things *really* complicated in the options, which would end up making it incredibly difficult to work in *any* way...
 
I did had a fault proof alternative build with js. But with adsense starting at DOM it was quite complicated on the clients side.

I will think of a server / client mix for a solution.
 
Yeah, you could of course do it with some JavaScript trickery, but then it starts getting really complicated trying to move something around the DOM with JS, and then you run into issues if the style changed enough that the DOM is different.
 
Just for others so they know what this is about. Imagine a thread on page three with these post_ids:

301
304
350
466
860
990

If you have never read the topic, and you are redirected to /post/860, the browser scrolsl down to #post-860 while the unread link will point to the first post #301 on this page (where the ad appears), even if the unread link should (!) redirect to the first post on the first page.

Whenever the user is using the thread route to enter the page as with threads/334 or threads/334/unread your script works flawless.

However if the user access the page with other routes as post, it won't work. /post/990 will redirect the user to page three and the browser will scroll down to #post-990, but the post_id where the ad will be displayed is the one that matches the unread post id on the same page, and that will be #301.

Imagine post #350 is the first unread post id for the user. When this user accesses this page, this post will be the one where the ad appears. But the user can access other posts with posts/301, posts/990, and by accident also hitting the right post with posts/350.
 
My solution was to put in the javascript ad code to every (!) post on the given page, embedded within another javascript that checks if the page anchor equals the actual post id. With that, the javascript is only executed when the equation works out. This is a fault proof method and it works for every urls, and it doesn't matter which routes the user took to display the page, threads/1234/unread works as well as posts/3948.

This is the only solution I found that works with adsense. As adsense code starts to display on EXACTLY the HTML place, where it is executed first. So if you put adsense banners on one post and write a javascript to move the ad around, the adsense ad will stay put at the place first executed, no matter what. You don't mess with the adsense javascript around, you can't move it.
 
There are some solutions and I would like to have your opinions about them:

1. Try to get rid of other routes than /threads/ as much as possible. As only /threads/ are covered by the unread post id idea. That would mean to rewrite templates and change <xen:link posts to <xen:link threads. Which is quite messy. But of course it's also better for SEO.

2. Same as one, but here rewrite any /posts/ route internally to /threads/. Whenever there is a <xen:link posts>, a threads/ link will be displayed. And that would also work internally within xf. I think this is the best way.

3. When the page is displayed, check with a javascript if the page anchor is really the unread post id. If yes, don't do anything. But if that's not the case, then deactivate the displaying ad with javascript and activate the javascript at the anchor's post id.
 
While there may be some solutions that work, to be honest, I don't think any are really clean enough to matter. Every thing I've come up with has been pretty hackish and just feels like it would break on future XF upgrades or with people using custom styles and such.
 
im getting this errors in xf server error log

Error Info
ErrorException: Undefined index: - library/DigitalPointAdPositioning/ViewPublic/Thread/View.php:34
Generated By: Unknown Account, Yesterday at 9:35 PM
Stack Trace
#0 /home/romney/public_html/library/DigitalPointAdPositioning/ViewPublic/Thread/View.php(34): XenForo_Application::handlePhpError(8, 'Undefined index...', '/home/romney/publ...', 34, Array)
#1 /home/romney/public_html/library/Tinhte/XenTag/XenForo/ViewPublic/Thread/View.php(5): DigitalPointAdPositioning_ViewPublic_Thread_View->renderHtml()
#2 /home/romney/public_html/library/XenForo/ViewRenderer/Abstract.php(215): Tinhte_XenTag_XenForo_ViewPublic_Thread_View->renderHtml()
#3 /home/romney/public_html/library/XenForo/ViewRenderer/HtmlPublic.php(67): XenForo_ViewRenderer_Abstract->renderViewObject('XenForo_ViewPub...', 'Html', Array, 'thread_view')
#4 /home/romney/public_html/library/XenForo/FrontController.php(533): XenForo_ViewRenderer_HtmlPublic->renderView('XenForo_ViewPub...', Array, 'thread_view', NULL)
#5 /home/romney/public_html/library/XenForo/FrontController.php(156): XenForo_FrontController->renderView(Object(XenForo_ControllerResponse_View), Object(XenForo_ViewRenderer_HtmlPublic), Array)
#6 /home/romney/public_html/index.php(13): XenForo_FrontController->run()
#7 {main}
Request State
array(3) {
["url"] => string(57) "http://www.obama.com/threads/i-love-romney.1822/page-4"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 
Top Bottom