diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index d5861887..9016c50b 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -98,6 +98,30 @@ class pluginDisqus extends Plugin { public function siteBodyEnd() { + global $Page, $Post, $Url, $posts; + + switch($Url->whereAmI()) + { + case 'post': + $absolutePermalink = $Post->permalink(true); + $uniqueId = $Post->uniqueId(); + $disqusTitle = $Post->title(); + break; + case 'page': + $absolutePermalink = $Page->permalink(true); + $uniqueId = $Page->uniqueId(); + $disqusTitle = $Page->title(); + break; + + default: + // Homepage - use the first post + if(isset($posts[0])) { + $absolutePermalink = $posts[0]->permalink(true); + $uniqueId = $posts[0]->uniqueId(); + $disqusTitle = $posts[0]->title(); + } + } + if( $this->enable ) { $html = ' @@ -105,6 +129,12 @@ class pluginDisqus extends Plugin { var disqus_shortname = "'.$this->getDbField('shortname').'"; + var disqus_config = function () { + this.page.url = "'.$absolutePermalink.'"; + this.page.identifier = "'.$uniqueId.'"; + this.page.title = "'.$disqusTitle.'"; + }; + (function() { var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true; dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";