Jump to content

nbcommunication

Members
  • Content Count

    125
  • Joined

  • Last visited

  • Days Won

    1

nbcommunication last won the day on July 25 2019

nbcommunication had the most liked content!

Community Reputation

165 Excellent

About nbcommunication

  • Rank
    Distinguished Member

Profile Information

  • Gender
    Not Telling
  • Location
    Lerwick, Shetland

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. That didn't take long - @kkalgidim, if you re-download (should now be version 1.4.1) then hopefully that'll work for you.
  2. @kkalgidim - looks like PHP < 5.6. Arrays in class constants are allowed from 5.6 onwards. You really should be on 7.2 or above! Given that ProcessWire supports 5.4 and above, I'll look into tweaking this so you can install. Cheers, Chris
  3. Hi @kkalgidim, What PHP version are you running? Cheers, Chris
  4. Updated to 1.0.1 (Stable), mainly reducing hook priority < 200 so it runs before ProCache.
  5. Hi @jonatan, You would probably need to do something like: var resetPagination = new Promise(function (resolve, reject) { var xhr = new XMLHttpRequest(); xhr.open("GET", window.location.href); oReq.addEventListener(xhr, "load", function() { if (xhr.status === 0 || xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { resolve(xhr); } else { reject(); } }); oReq.addEventListener(xhr, "error", function() { reject(); }); oReq.addEventListener(xhr, "timeout", function() { reject() }); xhr.send(); }); resetPagination.then(function() { instagram.init(); }, function() { // Error }); If I remember correctly, this kind of plain Javascript request doesn't actually register as an ajax request, so $config->ajax returns false, and the pagination will be reset. I'm not sure this is the best way to go though - I'd probably be trying to store the requested data in an array/object and then just pull it from there when the page changes e.g. var requests = {}, var items = []; // On page change var page = "page" + pageNum; // whereever you get this info from if(page in requests) { items = requests[page]; } else { items = "an AJAX request to get the next page of items"; requests[page] = items; } It will probably require a bit of reworking of your code, but it's a far better way to go. You shouldn't have to request the data more than once - store it! Hope that helps, Chris
  6. Hi, Update to 1.3.3 - tweak to how the cache name/key is generated, shouldn't effect anything... Cheers, Chris
  7. Hi @jonatan, Nice one! No thanks required - you've highlighted issues which has made the module significantly better! Cheers, Chris
  8. Hi @LAPS, I've added a setCampaign() method. It is essentially an alias for addTags(), but takes multiple string arguments instead of an array like addTags(). <?php $mg->to("an@email.com") ->subject"A Subject") ->setCampaign("campaign1", "campaign1-a", "testing") ->bodyHTML("<p>A Message</p>") ->send(); It also enables open and click tracking by default, as this is presumably behaviour you want for campaign analytics. If this isn't required, using addTags() is the way to go, but you can also pass false as the first argument to disable this behaviour and use whatever tracking settings you have by default. Cheers, Chris
  9. Hi @LAPS, OK - I'll take a look at this tomorrow and implement a method for this. Cheers, Chris
  10. Hi @LAPS, Campaigns isn't something I have experience with, but is it not a reporting system in Mailgun for analysing/comparing messages? From what I can gather, this uses message data and/or tags to do this, both of which are already implemented in the module. There isn't anything available in the API specifically related to campaigns. Is there another implementation you'd like to see, something like a setCampaign() method which adds the message data? Cheers, Chris
  11. The API issue with account_type has been resolved, so I've reinstated this in the module, version 1.3.2.
  12. Hi @jonatan, I'm not sure what more I'd be able to do to directly help here. At this point your best bet is to add a bunch of logging to try and determine where the problem is occurring. For example: // Attach listener console.log("Should only log once on init"); $(window).scroll(this.debounce(function() { console.log("Probably not needed, this will log during scrolling"); if(!this$1.busy && $(window).scrollTop() == $(document).height() - $(window).height()) { console.log("User has reached the bottom."); // When this is logged I should really only see one at the time due to the debounce function and the 'busy' switch. this$1.get(); // Similar logging to be added to get() } }, 256)); <?php $instagram = $modules->get("InstagramBasicDisplayApi"); // The next url is stored in session. The code below will log it. $instagram->log($session->getFor($instagram, "next$page->id")); if($config->ajax) { $instagram->log("You may want to log here to test how often AJAX requests are made"); header("Content-Type: application/json"); echo $instagram->getMedia(); // ["json" => true] is inferred by $config->ajax die(); } By using logging to trace the process, you will hopefully be able to figure out what is causing the issue. I suspect it is still the listener. Cheers, Chris
  13. Hi @houseofdeadleg, Seems to be an issue on the APIs end with the "account_type" field. There's an open bug report: https://developers.facebook.com/support/bugs/1127960260870980/ I've updated the module to remove this field for the time being. If you update, it should work for you. Cheers, Chris
  14. Hi @jonatan, Aye it is the listener. Try the following: var instagram = { $el: {}, // Where the items go $loading: {}, // The loading spinner total: 0, // The total number of items busy: false, init: function() { this.$el = $("#instagram"); if(!this.$el.length) return; // Add the spinner this.$el.after("<div id='instagram-loading'><span class='loadertextcontainer'><b class='loadertext'>loading<span>_</span><span>_</span><span>_</span></b></span></div>"); this.$loading = $("#instagram-loading"); this.$loading.hide(); // Get the first batch of items this.get(); var this$1 = this; // Attach listener $(window).scroll(this.debounce(function() { if(!this$1.busy && $(window).scrollTop() == $(document).height() - $(window).height()) { this$1.get(); } }, 256)); }, debounce: function(func, wait, immediate) { var timeout; if(wait === void 0) wait = 256; return function() { var context = this; var args = arguments; var later = function() { timeout = null; if(!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if(callNow) func.apply(context, args); }; }, get: function() { var this$1 = this; // Show spinner this$1.$loading.show(); // Prevent requests while this one is running this$1.busy = true; // Request $.getJSON(window.location.href, function(data) { // Hide spinner this$1.$loading.hide(); if(!$.isArray(data) || !data.length) return; // If no items do not render var items = []; data.forEach(function(item, index) { switch(item.type) { case "VIDEO": items.push(this$1.renderItemVideo(item.src, item.alt, item.href, index, item.poster)); break; case "CAROUSEL_ALBUM": var out = ""; for(var i = 0; i < item.children.length; i++) { var src = item.children[i].src; if (i <= 0) { out += "<a class='carousel-item active fb-gallery-ig' data-height='600' data-caption='" + item.href + "' href='" + src + "'>" + "<div style='background-image: url(" + src + ")' class='pics'></div>" } else { out += "<a class='carousel-item fb-gallery-ig' data-height='600' data-caption='" + item.href + "' href='" + src + "'>" + "<div style='background-image: url(" + src + ")' class='pics'></div>" } +"</a>"; } items.push( "<div data-interval='3000' class='carousel slide carousel-fade col-12 col-sm-6 col-md-4 p-3 pics' data-ride='carousel' id='instagram-item-" + (this$1.total + index) + "'>" + "<div class='carousel-inner'>" + out + "<a class='carousel-control-prev' href='#instagram-item-" + (this$1.total + index) + "' role='button' data-slide='prev'>" + "<span class='carousel-control-icon-bg' aria-hidden='true'></span>" + "<span class='carousel-control-prev-icon' aria-hidden='true'></span>" + "<span class='sr-only'>Previous</span>" + "</a>" + "<a class='carousel-control-next' href='#instagram-item-" + (this$1.total + index) + "' role='button' data-slide='next'>" + "<span class='carousel-control-icon-bg' aria-hidden='true'></span>" + "<span class='carousel-control-next-icon' aria-hidden='true'></span>" + "<span class='sr-only'>Next</span>" + "</a>" + "</div>" + "</div>" ); break; default: // IMAGE items.push(this$1.renderItem(item.src, item.alt, item.href, index)); break; } }); var count = items.length; if(count) { // Append items to the container this$1.$el.append(items.join("")); // Allow more requests this$1.busy = false; // Update total this$1.total = this$1.total + count; } }, function(e) { this$1.$loading.hide(); console.log(e); // ERROR }) }, renderItem: function(src, alt, href, index, poster) { return "<div class='col-12 col-sm-6 col-md-4 p-3 pics' id='instagram-item-" + (this.total + index) + "'>" + "<a class='fb-gallery-ig' data-height='600' data-caption='" + href + "' href='" + src + "' data-alt='" + alt + "'>" + "<div style='background-image: url(" + src + ")' class='pics'>" + "</div>" + "</a>" + "</div>"; }, renderItemVideo: function(src, alt, href, index, poster) { return "<div class='col-12 col-sm-6 col-md-4 p-3 pics' id='instagram-item-" + (this.total + index) + "'>" + "<a class='fb-gallery-ig' data-height='600' data-caption='" + href + "' href='" + src + "'>" + "<div style='background-image: url(" + poster + ")' class='pics'>" + (src !== poster ? "<div class='overlay-video-icon'></div>" : "") + "</div>" + "</a>" + "</div>"; } }; $(document).ready(function() { instagram.init(); }); I've added a "busy" variable which prevents requests when one is already being made, and a debounce function to control the scroll handler which has been moved to init(). Works for me. Cheers, Chris
  15. Hi @jonatan, It is probably related to the listener - when I get a chance I'll fire up the code and see if I can figure out a solution. Cheers, Chris
×
×
  • Create New...