Code Authors: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Code Authors Forum Index -> phpNuke Hints, Tips and Tweaks
Author Message
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 08, 2011 1:56 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

Inspired by the work done by Bobby over at www.trickedoutnews.com I thought I would integrate Disqus into my News (Tricked Out News 2.5E) module before he releases Tricked Out News 2.6 with the Disqus modifications already done.

Simple enough after registering for a free account at www.disqus.com

In modules/News/article.php
FIND
Code:
if (empty($mode)

comment out that line and all the code down to and including the line before
Code:
include_once 'footer.php';


Above this commented out section of code, ADD the following code after replacing your DISQUS_SHORT_NAME with your disqus shortname provided in your Disqus account.

Code:
// Disqus

   $articleurl = $nukeurl.'/article'.$sid.'.html';
   OpenTable();
   echo '<div></div>
   <script>
   //<CDATA>
   </script>
   <noscript>Please enable JavaScript to view the <a>comments powered by Disqus.</a></noscript>
   <a>Comments powered by <span class="logo-disqus">Disqus</span></a><br>';
   CloseTable();
   // Disqus

The above section of code was supplied by spasticdonkey from this thread; http://www.trickedoutnews.com/ftopict-126.html I have just added CDATA tags so the comments only display once all the background work is finished.

I have applied and been accepted for a Developers API key, so I may expand on this with a view to creating some sort of 'global' commenting system, provided the API allows remote access. In essence, possibly a Comment module to allow you to remotely manage your Disqus account.

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 08, 2011 6:20 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

Just to gauge how easy Disqus is to integrate with something that actually never had user comments, I have just added Disqus to my Content Plus module. Only took about 10 minutes so I'm quite impressed with it so far Smile

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
sortilege2021
Newbie
Newbie



Joined: Feb 09, 2011
Posts: 2

PostPosted: Wed Feb 09, 2011 6:46 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

thanks for share it, how to add disqus in the module nuketube?
 
View user's profile Send private message
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Wed Feb 09, 2011 7:35 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

All the information you need is posted or linked to above ^^

I'm actually looking at other ways to implement it, one a PHP Class and the other a jQuery plug-in. The code I have used here is pretty much the same as the code available on the Disqus website. It is just a matter of having a unique indentifier so the comments get linked to a specific piece of information.

Unfortunately time doesn't allow me to write a full tutorial, though a couple of clients have expressed an interest in having some modules modified to use Disqus that did not have any commenting facility originally.

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
sortilege2021
Newbie
Newbie



Joined: Feb 09, 2011
Posts: 2

PostPosted: Wed Feb 09, 2011 7:44 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

thanks
 
View user's profile Send private message
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Wed Feb 09, 2011 7:51 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

If you need help and are not in a rush, feel free to PM me and I'll try and do what I can.

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
montego
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 308

PostPosted: Tue Feb 15, 2011 11:18 am Share on Linked InShare on FacebookShare on Twitter Reply with quote

Exciting stuff Guardian, especially the site-wide commenting system. I think it should be a fairly easy do either withing footer.php or if need be, via a theme or even page-level ShortLink substitution. Nothing says one has to look for just a link pattern to replace... Wink Last resort of course...

_________________
Where Do YOU Stand?
HTML Newsletter :: ShortLinks :: DynamicTitles :: Approved Membership Lite :: And more... 
View user's profile Send private message Visit poster's website
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 15, 2011 11:56 am Share on Linked InShare on FacebookShare on Twitter Reply with quote

Regarding site wide commenting system;
I am now using Disqus here, it is very simple to integrate and since Tricked Out News already comes with the requisite disqus.php file which contains a few simple functions to do the grunt work, I'm not sure about the benefits of developing a seperate commenting system.

I spent 2 days playing with a comment administration system for Disqus to allow you to remotely access Disqus using their API to manage comments; edit/delete/flag as spam etc etc and using the API itself to display the 'comment' code for posting comments (instead of the method used here).
However, I ran into a deal breaker. The standard 'free' Disqus account only allows 1000 accesses to their API per hour and I just don't think that limitation justifies further development as most people will be using the 'free' Disqus account and can do everything from their account at Disqus any way.

The current implementation here of Disqus requires very few changes to 'core' code;
include the disqus.php file
modify page links or link building techniques that you need comments for by altering the link to add #disqus_thread to the link - easy as that!

Although Disqus seems to handle links to the same page very well i.e. Shortlinked and none ShortLinked url's I would recommend using something similar to the code below to as good practise.

Code:
if (defined('TNSL_USE_SHORTLINKS')){

      $pageurl = $nukeurl."/article$sid.html";
        } else {
      $pageurl = $nukeurl.'/modules.php?name=News&file=article&sid='.$sid.'';
   }

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
montego
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 308

PostPosted: Tue Feb 15, 2011 1:12 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

Ok. Good to know.

Regarding having core code produce the shortened links, it would be even better to create a Link Factory class(es) as a core RN API... If and when I get back to working on my next major revision to ShortLinks (2.x), its going to create this if the RN doesn't get there first. It is really needed IMO along with a few other core APIs.

_________________
Where Do YOU Stand?
HTML Newsletter :: ShortLinks :: DynamicTitles :: Approved Membership Lite :: And more... 
View user's profile Send private message Visit poster's website
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 15, 2011 1:40 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

I could not agree more!
A Link Factory type API is really needed, along with a user management/authentication/permissions API and a few others I can think of BUT here is the kicker; is it actually worth it?
I am really, really struggling with the whole 'piecemeal' approach to RN now because every time, it requires third party modules to be re-written or themes to be re-written and so on...
Personally, I am at the stage where I would just like to use a framework and get it over with, instead of taking incremental steps to reach what will be no doubt the same end stage.

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
spasticdonkey
Newbie
Newbie



Joined: May 12, 2009
Posts: 74
Location: TX

PostPosted: Tue Feb 15, 2011 4:17 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

is there a link factory class that looks particularly attractive?
 
View user's profile Send private message Visit poster's website
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 15, 2011 6:09 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

I haven't found/seen one as yet.
I did use this as a base when building my Shop though
http://josephscott.org/archives/2008/11/php-url-routing-pur/

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
Guardian
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 4465
Location: Vsetin, Czech Republic

PostPosted: Tue Feb 15, 2011 6:46 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

I actually broke it down a little more than the above article because OOP still confuses me at times.
I ended up using different files to perform different tasks.
Taking the Shop here as an example, for my content pages;
In htaccess, to redirect to the correct file I use something like
Code:
RewriteRule view-content/(.*)-(.*)\.html$ content.php?id=$1&title=$2

This redirects the request to the 'handler' file which is content.php
In content.php I perform some routine checks and sanitisation on POST id
Then get the data;
Code:
$template->set($content->getPageById($id));

Then display the data.
Linking structure is based on the following type of code ($slug being whatever I have set for the page when I wrote it as it's stored in the DB but defaults to the page 'title');
Code:
$display = $config->settings['site-url'] . '/view-content/' . intval($id) . '-' . sanitise($slug) . '.html';

_________________
TPD 
View user's profile Send private message Send e-mail Visit poster's website
montego
Site Admin
Site Admin



Joined: Jan 06, 2006
Posts: 308

PostPosted: Fri Feb 18, 2011 12:29 pm Share on Linked InShare on FacebookShare on Twitter Reply with quote

@Spastic - the way I am forced to "work" is formulate the concept in my mind of what my "requirements" are, but then I need to put them on the "shelf" to dust off at a time in the future when I have the time to work on it. At that point, I would do the needful research. So, I haven't looked for one, but I've used several tools (Wordpress, b2evolution, etc) that do this well, so I have seen how it could work.

@Guardian - Regarding "piecemeal"... wish I could disagree with you. Without focused resources to dedicate their time, piecemeal is the best we seem to be able to get. Just the nature of the beast. Sad I'm just as guilty all these years.

_________________
Where Do YOU Stand?
HTML Newsletter :: ShortLinks :: DynamicTitles :: Approved Membership Lite :: And more... 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Code Authors Forum Index -> phpNuke Hints, Tips and Tweaks

View next topic
View previous topic
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

 
Forums ©
linear-bunch
linear-bunchlinear-bunch