Tricked Out News

Welcome to TON. This site is dedicated to development of addons for the RavenNuke™ CMS
Follow Us:
Tricked Out Mods: Forums

 Forum FAQForum FAQ   SearchSearch   UsergroupsUsergroups   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to add Disqus to news
 Goto page 1, 2  Next
 
Post new topic   Reply to topic   print    Tricked Out News Forum Index -> RavenNuke
View previous topic :: View next topic  
Author Message
bobby
Site Admin
Site Admin


Joined: Jan 20, 2009
Posts: 600
Location: North Carolina
Reputation: 543Reputation: 543Reputation: 543
votes: 4

PostPosted: Sat Nov 20, 2010 9:57 am 
Post subject: How to add Disqus to news
Reply with quote

This is how to add the Disqus commenting system to the Tricked Out News 2.5. You should also be able to do the same with the standard news module although the code to replace will be different.

The first thing to do is head over to http://disqus.com/ and create an account. Once you create your Disqus account, you can customise it in their dashboard. You will need to copy their Install Universal Code to a good editor such as Notepad++. Their code will have 2 parts, the Embed code and the Comment count. Keep the two codes separate.

You will need to edit their code a little bit. First in the Embed Code find:

Code:


/**
    * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
    */


and replace it with:

Code:
var disqus_identifier = "'.$sid.'";   


so that the new code looks like this:

Code:
<script type="text/javascript">

var disqus_identifier = "'.$sid.'";   
  (function() {


Next, you will need to replace the single quotes with double quotes like so:
'script' becomes "script"
'text/javascript' becomes "text/javascript"
etc...


There are 5 sets of quotes that need to be changed in the Embed code and 5 in the Comment Count code.
Save these codes and get ready to start editing your site.

In your News/articles.php, find the following code starting at around line 345:

Code:
if (empty($mode) OR $mode != 'nocomments' OR $acomm == 0 OR $articlecomm == 1) {



From there all the way to the end will be replaced with the new code. So you will start there and remove ALL the code to the end of the file and replace it with this:

Code:
//Start Disqus

if ($anonpost==1 OR (isset($admin) AND (is_admin($admin) AND $acomm == 0)) OR (is_user($user) AND $acomm == 0)) {
global $db, $prefix, $cookie;
cookiedecode($user);
if (count($cookie)<2) $uname='';
else $uname = $cookie[1];

global $db, $prefix;

$sql = 'SELECT user_email FROM '.$user_prefix.'_users WHERE username = \''.$uname.'\'';
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $user_email = $row['user_email'];
   
if (is_user($user)) {
echo'
<script type="text/javascript">
var disqus_skip_auth = true;
var disqus_def_name = "'.$uname.'";
var disqus_def_email = "'.$user_email.'";
</script>';
}
echo'Paste Disqus Embed code Here';

echo'Paste Disqus Comment Count code Here';
}
// End Disqus
include_once ('footer.php');

?>


Of course, you will need to paste your edited Embed code and Comment code where it says to Paste your code in this mod.

That should do it. Be sure to back up your site before starting.
_________________
Tricked Out News
  
Back to top
View user's profile Send private message
Palbin
Regular
Regular


Joined: May 23, 2009
Posts: 15

Reputation: 19.4Reputation: 19.4

PostPosted: Sat Nov 20, 2010 10:52 am 
Post subject:
Reply with quote

Are you aware that OpenID and Yahoo do not work on this site? The menu goes away when you go past facebook. Just an FYI I am using latest firefox.
  
Back to top
View user's profile Send private message
bobby
Site Admin
Site Admin


Joined: Jan 20, 2009
Posts: 600
Location: North Carolina
Reputation: 543Reputation: 543Reputation: 543
votes: 4

PostPosted: Sat Nov 20, 2010 12:37 pm 
Post subject:
Reply with quote

Thank you, I will look into it.I hope it's not a conflict with CloudFlare.
_________________
Tricked Out News
  
Back to top
View user's profile Send private message
RamonTF
Regular
Regular


Joined: Mar 17, 2009
Posts: 11

Reputation: 3.7Reputation: 3.7Reputation: 3.7

PostPosted: Sat Nov 20, 2010 4:16 pm 
Post subject:
Reply with quote

Thanks a lot, I'm testing now but seems not working o my local installation. Also there is a required setting that you did not mentioned:

Code:
var disqus_shortname = "example";

_________________
"Who controls the past controls the future. Who controls the present controls the past."--George Orwell
  
Back to top
View user's profile Send private message
bobby
Site Admin
Site Admin


Joined: Jan 20, 2009
Posts: 600
Location: North Carolina
Reputation: 543Reputation: 543Reputation: 543
votes: 4

PostPosted: Sat Nov 20, 2010 4:26 pm 
Post subject:
Reply with quote

When disqus supplied me with the universal code, it was already in there.

In disqus, in the top right, click switch to old disqus.

click on comments and then click install instructions from the drop down at your discus name. Those instructions should have the info already there. i don't know why the new disqus does not have that filled in for you.
_________________
Tricked Out News
  
Back to top
View user's profile Send private message
bobby
Site Admin
Site Admin


Joined: Jan 20, 2009
Posts: 600
Location: North Carolina
Reputation: 543Reputation: 543Reputation: 543
votes: 4

PostPosted: Sat Nov 20, 2010 4:38 pm 
Post subject:
Reply with quote

If you still have problems, send me your code in a pm and I will set it up for you. You also have to make sure your site that is using the code is added at Disqus.
_________________
Tricked Out News
  
Back to top
View user's profile Send private message
RamonTF
Regular
Regular


Joined: Mar 17, 2009
Posts: 11

Reputation: 3.7Reputation: 3.7Reputation: 3.7

PostPosted: Sat Nov 20, 2010 4:52 pm 
Post subject:
Reply with quote

Ok, I see now the proper code, thanks Smile
_________________
"Who controls the past controls the future. Who controls the present controls the past."--George Orwell
  
Back to top
View user's profile Send private message
bobby
Site Admin
Site Admin


Joined: Jan 20, 2009
Posts: 600
Location: North Carolina
Reputation: 543Reputation: 543Reputation: 543
votes: 4

PostPosted: Sun Nov 21, 2010 12:40 am 
Post subject:
Reply with quote

To add the comment count to the index:

In the modules/News/index.php, find:
Code:


$story_link = '<a href="news.html?amp;file=article&amp;sid=' . $sid . '">';

after that add:
Code:


$hometext = $hometext.'<br /><br /><script type="text/javascript">
     var disqus_shortname = "Your Shortname";
var disqus_identifier = "'.$sid.'";
      (function () {
        var s = document.createElement("script"); s.async = true;
        s.type = "text/javascript";
        s.src = "http://disqus.com/forums/" + disqus_shortname + "/count.js";
        (document.getElementsByTagName("HEAD")[0] || document.getElementsByTagName("BODY")[0]).appendChild(s);
    }());
</script><img src="images/news/comment.png" alt="Comments" /><a style="font-size:13px; font-weight:bold;" href="modules.php?name=N ews&amp;file=article&amp;sid=' . $sid . '#disqus_thread"></a>';


You will need to change Your Shortname to the shortname Disqus gave you. You will also need to remove the space in the bottom link in the word N ews. Shortlinks rewrites it on my site if i do not leave the space in it. I added some simple styling to the link, you can change it to your liking.
_________________
Tricked Out News
  

Last edited by bobby on Sun Nov 21, 2010 9:52 am; edited 2 times in total
Back to top
View user's profile Send private message
RamonTF
Regular
Regular


Joined: Mar 17, 2009
Posts: 11

Reputation: 3.7Reputation: 3.7Reputation: 3.7

PostPosted: Sun Nov 21, 2010 8:39 am 
Post subject:
Reply with quote

Yeah! this work like a charm!

... but I've modified some code for this work fine for me

The correct code for me is:

Code:
$hometext = $hometext.'<br><br><script>

           var disqus_shortname = "myshortname";
           var disqus_identifier = "'.$sid.'";
          (function () {
           var s = document.createElement("script"); s.async = true;
           s.type = "text/javascript";
           s.src = "http://disqus.com/forums/" + disqus_shortname + "/count.js";
          (document.getElementsByTagName("HEAD")[0] || document.getElementsByTagName("BODY")[0]).appendChild(s);
          }());
          </script><div align="right"><img src="images/news/comment.png" alt="Comments" align="absmiddle">&nbsp;<a href="news.html?amp;file=article&amp;sid=' . $sid . '#disqus_thread"></a></div>';


With the other code the link on the counter lead me to an error page (I think, shortlinks issue). Also note the point (.) afther the "$hometext = $hometext.[..]"

I think this is a great addition to the news, good work.
_________________
"Who controls the past controls the future. Who controls the present controls the past."--George Orwell
  
Back to top
View user's profile Send private message
RamonTF
Regular
Regular


Joined: Mar 17, 2009
Posts: 11

Reputation: 3.7Reputation: 3.7Reputation: 3.7

PostPosted: Sun Nov 21, 2010 8:46 am 
Post subject:
Reply with quote

lol, the shortlinks mod changed the "long link" on the code bbcode!

The href must be the real link to the article not the rewrited one!.
_________________
"Who controls the past controls the future. Who controls the present controls the past."--George Orwell
  
Back to top
View user's profile Send private message
bestbuildpc
I might as well work here
I might as well work here


Joined: Nov 16, 2009
Posts: 61

Reputation: 20.5Reputation: 20.5

PostPosted: Sun Nov 21, 2010 9:32 am 
Post subject:
Reply with quote

I can not make it work with this code. I get an error

Code:
$hometext = $hometext'<br><br><script>


But after adding a dot in front of $hometext. It works.

Code:
$hometext = $hometext. '<br><br><script>


I still get an error on doing this mod. It will be nice to see those 2 files mod. Thanks in advance
  
Back to top
View user's profile Send private message Visit poster's website
bobby
Site Admin
Site Admin


Joined: Jan 20, 2009
Posts: 600
Location: North Carolina
Reputation: 543Reputation: 543Reputation: 543
votes: 4

PostPosted: Sun Nov 21, 2010 9:44 am 
Post subject:
Reply with quote

That's right. sorry, I left the dot off. I will change it. I always forget about ShortLinks rewriting links in the forums. I adjusted the code above to include the . and the correct link with a space in it so it is viewable.
_________________
Tricked Out News
  
Back to top
View user's profile Send private message
sortilege2021
Regular
Regular


Joined: Nov 25, 2010
Posts: 16

Reputation: 5.6Reputation: 5.6Reputation: 5.6Reputation: 5.6Reputation: 5.6

PostPosted: Fri Dec 10, 2010 8:15 pm 
Post subject:
Reply with quote

great! i'll try to do it on my local instalation.

last night i tried to get the universal code but i believe that service is not working temporaly
  
Back to top
View user's profile Send private message
bobby
Site Admin
Site Admin


Joined: Jan 20, 2009
Posts: 600
Location: North Carolina
Reputation: 543Reputation: 543Reputation: 543
votes: 4

PostPosted: Sat Dec 11, 2010 12:47 pm 
Post subject:
Reply with quote

I will put a download package together where you will only need to enter your short name in as a variable. It seems Disqus is being difficult today.
_________________
Tricked Out News
  
Back to top
View user's profile Send private message
sortilege2021
Regular
Regular


Joined: Nov 25, 2010
Posts: 16

Reputation: 5.6Reputation: 5.6Reputation: 5.6Reputation: 5.6Reputation: 5.6

PostPosted: Sat Dec 11, 2010 1:03 pm 
Post subject:
Reply with quote

great! i will be wait for it!
  
Back to top
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic   print    Tricked Out News Forum Index -> RavenNuke All times are GMT - 5 Hours
 Goto page 1, 2  Next
 Page 1 of 2

 

Jump to:   
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001-2008 phpBB Group
Forums ©