Skip to content

Commit fe723e5

Browse files
support disqus comments in extension theme
1 parent 64180f3 commit fe723e5

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

config/letsblog.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@
123123
'facebook' => 'saywebsolutions',
124124
],
125125

126+
'comments' => [
127+
128+
'enabled' => false,
129+
130+
'disqus' => [
131+
132+
//add your disqus shortname here
133+
'shortname' => '',
134+
135+
],
136+
],
137+
126138
'footer' => [
127139
'copy' => true,
128140
'plug' => true,

resources/views/themes/extension/post/show.blade.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,47 @@
4141
@section ('post.related')
4242
@include (lb_view('components.related'))
4343
@show
44-
45-
</div>
4644

45+
</div>
4746
</div>
4847

48+
@if ( ! empty(config('letsblog.comments.enabled', false)))
49+
<?php
50+
51+
$comments = config('letsblog.comments.enabled', false);
52+
53+
switch ($comments) {
54+
case 'disqus':
55+
?>
56+
57+
<div id="disqus_thread"></div>
58+
<script>
59+
60+
/**
61+
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
62+
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
63+
var disqus_config = function () {
64+
this.page.url = "{{ \Request::fullUrl() }}"; // Replace PAGE_URL with your page's canonical URL variable
65+
this.page.identifier = "{{ $post->slug }}"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
66+
};
67+
(function() { // DON'T EDIT BELOW THIS LINE
68+
var d = document, s = d.createElement('script');
69+
s.src = 'https://{{ config('letsblog.comments.'.$comments.'.shortname') }}.disqus.com/embed.js';
70+
s.setAttribute('data-timestamp', +new Date());
71+
(d.head || d.body).appendChild(s);
72+
})();
73+
</script>
74+
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
75+
76+
<?php
77+
break;
78+
79+
default:
80+
break;
81+
}
82+
?>
83+
@endif
84+
4985
@push('scripts')
5086

5187
<script charset="utf-8">

0 commit comments

Comments
 (0)