Comments

RKopacz’s picture

Subscribing.

breathingrock’s picture

Assigned: Unassigned » breathingrock
Status: Active » Needs review
StatusFileSize
new11.83 KB

Attached is a patch that should get you off the ground. It does NOT yet support AJAX. I'm currently working on that.

Tested myself, but let me know how it goes.

Tim

bleen’s picture

StatusFileSize
new10.21 KB
new9.23 KB

Wow! This is very cool ... Thanks Tim. I cant wait to see it workin with AJAX :)

I know it looks like I changed *a lot* here, but really I just moved around a bunch of code, made some coding standards fixes, added some comments, etc... (see the interdiff to see what I changed) functionally I havent changed anything. I'm going to continue to play though.

breathingrock’s picture

StatusFileSize
new25.93 KB

Attached is a patch (based off your patch, bleen18) with AJAX support.

Critiques/Feedback welcome.

Tim

bleen’s picture

Status: Needs review » Needs work

The only thing I see a problem with so far is that it violates Drupal policy to include a 3rd party JS library in a Drupal module. Can we instead add a link somewhere (maybe during install in a drupal_set_message() or if you try to turn on the ajax features or something like that)

ref: http://drupal.org/node/422996

This si really great though!! Thanks @breathingrock

Snugug’s picture

I'm looking at this patch, and using it in an attempt to see how it works, and the output isn't quite what I would expect.

First, the ad gets inserted into the row itself as opposed to a new row, so while it keeps the same number of items returned, the way most people would treat the ad would be as a separate entity, and because it's inserted into an existing row instead of a new row, we are unable to do this. A specific use case for this? Pulling in images using views to make a gallery, and having one slide be an ad. Can't do that with the current implementation.

Second, because it doesn't get added as a new row and gets appended to existing results, and additionally because it gets appended to the top of each result without an option to change that, there is currently no way to have an ad be the last result in a query. If I've got three items and I want the ad to be the fourth item, I expect the ad to show up regardless of whether or not there is a result there, not to simply not display (or at least an option to do so).

Snugug’s picture

The way the view row count carries between different views on the same page is also very unintuitive. I've got one view providing two separate blocks with different view modes. One has 3 items, one is a paged list. Both are being displayed on one page. The ad placement on one block is taking into consideration the number of views rows already on the page, producing undesired results. Example:

Block 1: Ad placement on 4, block has 3 results.
Block 2: Ad placement on 4, block has 4 results paged.

Results on page:

Block 1 item 1
Block 1 item 2
Block 1 item 3
Block 2 ad
Block 2 item 2
Block 2 item 3

This seems like a bug, not a feature, and an unexpected result. Also, not being able to set ads to repeat every N blocks is a killer, doubly so because we're only limited to three ad inserts and if we've got a long list of items, ads will stop when we will probably want them to keep going.

Snugug’s picture

Also, it seems as if it doesn't work with AJAX pagination, specifically with Views Load More enabled.

breathingrock’s picture

Snugug,

Give this patch a try.

The DART module doesn't declare its own entity type, but I have separated the ads and nodes into their own rows. This ought to take care of your primary concerns. Tested with multiple blocks on a page (along with the same view for page content) and all look to be working independently from one another.

I didn't have time to debug the Views Load More issues. And I wouldn't think implementing a every-nth-row feature would be that difficult. I'll see what I can do about these tasks by next weekend.

@bleen18 - I'll work your idea re: the WriteCapture library in with the above stuff as well.

Tim

Snugug’s picture

So! The new row stuff works an absolute charm! The issue that I'm now running into is, with the same setup as before, but now using any paged view mode (including Views standard pager), views_plugin_pager_full is timing out and throwing a PHP Fatal, preventing the page from rendering. This is with AJAX pagination. If I've got either "Display Set Number Of Items" or "Display All Items" as my pager mode, it all works fine. Any pager will WSOD the page.

breathingrock’s picture

Snugug,

I could not reproduce this problem. Could it be an incompatibility with another custom/contrib module? I'm working on a clean Drupal install with only a standard set of contrib modules enabled.

I'm going to see what I can do about the every nth ad position.

Tim

breathingrock’s picture

And here's a patch with an option for setting an ad position interval, i.e. displaying an ad every nth row.

Tim

breathingrock’s picture

bleen - and here's the same patch as above that removes the writeCapture library from the module and warns the user if the writeCapture library isn't detected when editing the ad position settings in the view.

bleen’s picture

There is a minuscule whitespace issue, but otherwise this looks great to me... Lets give Snugug a chance to test drive it and then I think we're ready to commit.

timverly++

+++ b/dart.views.incundefined
@@ -0,0 +1,26 @@
+	'title' => t('Content with DART Ads'),
+	'help' => t('Display the node with standard node view, but with a dash of DART.'),
+	'handler' => 'views_plugin_row_dart_node_view',
+	'path' => drupal_get_path('module', 'dart') . '/views',
+	'theme' => 'dart_views_view_row_node',
+	'base' => array('node'), // only works with 'node' as base.
+	'type' => 'normal',
+	'uses options' => TRUE,
+	'type' => 'normal',
+	'help topic' => 'style-node',

white space issue...

Snugug’s picture

This appears to be working with the exception of when choosing interval input and saving, Views spits out JSON instead of having the modal save and close. Do I need some JavaScript (it said something about writecapture jQuery being needed) in order for it to work properly?

breathingrock’s picture

Attached patch fixes the white space issue.

I uninstalled the WriteCapture library and couldn't replicate the JSON error. Not sure what could be causing it. Does everything point to this patch as the source of the problem on your end?

Btw, fixed the default interval values.

Snugug’s picture

Testing!

UPDATE:

Fresh DL of the module, patched, caches cleared. The "Content with DART Ads" option is available, but whenever I go to select it, the selection fails (apply, no options, style doesn't change).

Snugug’s picture

Another update!
I've gotten past the previous roadblock, and while a fixed number of items with either a fixed position or an interval position, the moment I add any pager, including the standard pagers, the view render times out (PHP Fatal error: Maximum execution time of 60 seconds exceeded). This is a pretty big blocker for this IMO.

bleen’s picture

I've gotten past the previous roadblock

... did this require any changes in code?

Snugug’s picture

Previous roadblock was re: needing to re-install WriteCapture to my Libraries folder, but still have the Max Execution Time errors and every once and a while Views will spit back JSON instead of the view editor still.

bleen’s picture

breathingrock: do you follow #20? Can you reproduce

breathingrock’s picture

Not getting either the timeouts / slow page loads or the JSON.

Snugug: Could you provide a .tgz of your codebase and a DB dump so I can install on my local?

breathingrock’s picture

Here's a patch with postscribe support. Haven't re-tested writecapture yet.

Snugug’s picture

Step 1) Create Drush command to download and install PostScribe.

Testing the rest now.

breathingrock’s picture

And here we've got writecapture support, as well as support for the load ads last feature already implemented in the module. The 2 didn't necessarily play nice.

bleen’s picture

snugug mentioned that something might have been missing from teh views plugin yesterday.... has that been resolved?

breathingrock’s picture

Fixing up Views library detection error message and export variables.

breathingrock’s picture

And this a bit more proper version of the above patch.

breathingrock’s picture

And additional support for static tags with AJAX views paging.

Snugug’s picture

The only issue I'm currently having is that repeating ads don't actually display multiple versions of the ad. The first ad loads in fine, the other two I have on the page do not load in, but without error. Otherwise, all of the other errors that I've had have been solved.

This, BTW, is being tested with an AJAX pager.

bleen’s picture

+++ b/js/dart_tag_ajax.jsundefined
@@ -0,0 +1,108 @@
+      return tag.replace(/;ord=/, ';' + (top.__nbcudigitaladops_dtparams || '') + 'ord=');

Cant have nbcudigitaladops specific code here...

breathingrock’s picture

Removed the nbcudigitaladops conditional.

breathingrock’s picture

bleen’s picture

I got a RTBC from Snugug in IRC today ... WOOOOT.

Committed to HEAD ... the only change I made was moving dart.js and dar.admin.js into the new js folder

Thanks!!

bleen’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jasom’s picture

Here is step-by-step tutorial how to insert custom code (adsense for example) after first and sixth row in your drupal 7 or drupal 8 views: http://www.jasom.net/how-to-add-custom-code-adsense-after-first-row-in-d...

Basically, you need to override your views-view-unformatted.tpl.php with this code

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>
  </div>
  <?php if ($id == 0 || $id == 5): ?>My custom code after first and sixth row in Drupal views<?php endif; ?>
<?php endforeach; ?>