Disqus in the cgblog module

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Disqus in the cgblog module

Post by carasmo »

DO IT IN ORDER:

Create 2 UDTs

1. currenturl

2. disqus


UDT called "currenturl" :

Code: Select all

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

echo curPageURL();

UDT called "disqus"

See UDT here: http://dev.cmsmadesimple.org/projects/disqus


That UDT is for NEWS, THESE instructions are for CGBlog

All you do in the UDT is ignore most of the the instructions except 2 things:

1. Change line #26 in the file to your disqus short name...

$d_Shortname = "thenameyouhavewithyourdisqusaccount"; //<--- #### CHANGE THIS BY YOU OWN "disqus shortname". More informations on http://disqus.com/


2. Before the body close tag on your PAGE template (not the detail template of the blog) past this:

Code: Select all

{disqus counter='whatever'}

Putting the code in the respective templates in CGBlog:

Summary template to show the links and comment count on the summary loop (this goes somewhere inside the foreach of each summary):

Code: Select all

<a href="{$entry->detail_url}#disqus_thread" title='see the comments' data-disqus-identifier="{$entry->detail_url}">&nbsp;</a>

Top of Detail template, remove old canonical information and replace with:

Code: Select all

{strip}{capture assign=sid}{currenturl}{/capture}
{if isset($entry->canonical)}
{assign var='canonical' value=$sid}{/if}{/strip}
This is because the $entry->detail_url is not the same as the canonical in the latest CGBlog module, it used to be.

Detail template (the link to the comments and showing of the comments)

Code: Select all

<a href="{$sid}#disqus_thread" title='see the comments' data-disqus-identifier="{$sid}">&nbsp;</a>
Put this where you want the comments and form to appear:

Code: Select all

{disqus comments=$sid}


All other stuff, formatting and words you need to learn how to use disqus and change appearances.

You can purchase the ability to adjust themes or you can use some css and target the ids and classes, I've done just enough to match my theme and use my fonts:

CSS

Code: Select all

#disqus_thread h3 {
text-transform:lowercase;
font-size:120%;
font-weight:normal!important;
}


#dsq-reply h3 {font-size:200%;font-weight: 300!important;}

#disqus_thread  {
color:#000;
font-weight:normal;
font-family: 'Lato', helvetica, arial, sans-serif;
font-size:90%;
}


#disqus_thread select  {
font-size:80%;
}

#disqus_thread a, #dsq-footer a {text-decoration: none!important;}

#dsq-content #dsq-footer * {text-decoration: none!important;}

div.dsq-trackback-url input {width:80%}

div.dsq-comment-header {border-color:#ddd}

a.dsq-brlink {text-decoration:none;display:block;width:100%;text-align:right}
NOTE: I also have global form css, example:

Code: Select all

input[type="text"],input[type="password"],input[type="email"], input[type="tel"],input[type="url"],textarea,select {stylesgohere}
I don't have time to support this, please be patient as the js running disqus is slowish and so comment counting doesn't show up for a little while. More stuff here: http://www.siterehab.com/disqus-custom-css/

You can change some of the wording in your disqus/ settings /appearance, but it only goes so far.
Screen Shot 2012-06-17 at 3.45.08 PM.png
Screen Shot 2012-06-17 at 3.45.34 PM.png
Screen Shot 2012-06-17 at 3.44.39 PM.png
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: Disqus in the cgblog module

Post by carasmo »

How to do the related posts thing for a post assigned to various categories:

http://forum.cmsmadesimple.org/viewtopi ... =4&t=61944
Last edited by carasmo on Sun Jul 29, 2012 3:15 pm, edited 1 time in total.
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: Disqus in the cgblog module

Post by carasmo »

General settings uncheck the "enable reactions" to turn this off. It looks better.
Attachments
Screen Shot 2012-06-17 at 4.40.41 PM.png
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: Disqus in the cgblog module

Post by carasmo »

BEFORE the following works you need this:

Also you will need the following BEFORE this works:

a DETAIL cgblog template in this case called "blogsearchresults"

Code: Select all

{capture assign='articleDate'}{$entry->postdate|cms_date_format}{/capture}

{capture assign="articleTitle"}{$entry->title}{/capture}

{capture assign="articleURL"}{$entry->canonical}{/capture}
Also, I encourage adjusting your search module template too. When a person searches my site, I want to take them to the exact page for the cgblog entry, not one with a "return id" in it. My return id is 74, yours is something else. If you currently click from a summary blog entry to the detail entry, you'll see something like:

Code: Select all

http://dropsoul.com/blog/36/Pure-CSS-Page-Curl-Effect.html
36 is the entry id

but if you find it through searching you'll get something like this:

Code: Select all

http://dropsoul.com/blog/36/74/...
74 is the return id

I don't want the return id because I have disqus running the comments and I also have other things like FaceBook's open graph where the url must be the same. Therefore my SEARCH template looks like this:

Code: Select all

<h1 class="headline">{$searchresultsfor} "{$phrase}"</h1>
{if $itemcount > 0}
<ul>
  {foreach from=$results item=entry}

{if (empty($entry->module)) || ($entry->module != 'CGBlog')}
<li>{$entry->title} &mdash; <a href="{$entry->url}">{$entry->urltxt}</a></li>
{/if}

{*start blog*}
{if $entry->module == "CGBlog"}
<li>{$entry->title} &mdash;
{capture assign="results"}{CGBlog action=detail articleid=$entry->modulerecord detailpage="blog" detailtemplate='blogsearchresults'}{/capture}
<a href="{$articleURL|regex_replace:"/(\/)74/":""}">{$articleTitle}&mdash;{$articleDate}</a>
</li>
{/if}
{*end*}


{/foreach}
</ul>

{else}
  <p><strong>{$noresultsfound}</strong></p>
{/if}
see the line:

Code: Select all

<a href="{$articleURL|regex_replace:"/(\/)74/":""}">{$articleTitle}&mdash;{$articleDate}</a>
that 74 is replaced with your own return id the detail page "blog" is also replaced with your own detail page where your blog is located.
Post Reply

Return to “Tips and Tricks”