Created
July 28, 2015 13:56
-
-
Save AlphaNerd/94599860228e4dfe3563 to your computer and use it in GitHub Desktop.
Disqus API Mod: Force Joomla to pull one Disqus thread for both English and French associated content. Swaps DisqusEmnbed.js [src attr] after initial load.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimeout(function(){ //// Timeout required to grab iFrame info after Disqus load | |
var newURL = jQuery(".moduletable-lang a").attr("href"); | |
var curURL = decodeURIComponent(jQuery("iframe").attr("src")); | |
var newTitle = "1211-new-brunswick-lagging-behind-other-parts-of-canada-on-wilderness-protection-cpaws-report"; | |
if (jQuery("body").hasClass("fr-fr")){ | |
createNewURL(newURL,newTitle,curURL); /// custome function to build new uri | |
} | |
},750); | |
function createNewURL(newURL,newTitle,curURL){ | |
disq_array = curURL.split("&"); | |
console.log("Reconstruct URL for Disqus..."); | |
console.log("New URL In --> ",newURL); | |
console.log("Decoded URL: ",disq_array); | |
var newUrlArray = newURL.split("/"); | |
newURL = ""; | |
for (j=3;j<newUrlArray.length;j++){ | |
newURL += newUrlArray[j]; | |
console.log(newURL); | |
} | |
disq_array[4] = "t_u=http://www.nben.ca/index.php/en/"+newURL; | |
disq_array[5] = "t_d="+newTitle; | |
disq_array[6] = "t_t="+newTitle; | |
var newDisqusSRC = disq_array[0]; | |
for (i=1;i<disq_array.length;i++){ | |
newDisqusSRC += "&"+disq_array[i]; | |
} | |
console.warn(newDisqusSRC); | |
jQuery("#dsq-1").attr("src",newDisqusSRC); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment