BlogHarbor Home Page
FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  UsergroupsRSS   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
More info in Recent Comments & Better Default Comment Na
 
Post new topic   Reply to topic    BlogHarbor Community Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
abacquer



Joined: 22 Mar 2004
Posts: 193

PostPosted: Mon Mar 07, 2005 6:06 pm    Post subject: More info in Recent Comments & Better Default Comment Na Reply with quote

oI have a few questions about customizing my recent comment list and other stuff... John, can you advise me on any of these?

(1) My Recent Comments component in my blogharbor sidebar shows only the title of the article. This makes it hard to see who commented and when.

What I would like to see instead of:
Quote:
Re: Re: thing
Re: thing
Re: Re: Re: spoon
Re: fork
Re: Re: spoon
is something more like this:
Quote:
03/02/05 Darryl: Re: Re: thing
03/02/05 Abacquer: Re: thing
03/01/05 Abacquer: Re: Re: Re: spoon
03/01/05 Anonymous: Re: fork
02/28/05 Abacquer: Re: Re: spoon
Where each person's name is a link to their user info page, and the title is the link to the comment anchor.

Is there any way for me to do that, or something like that? I had a couple readers complain to me privately that the comment list gives no context (other than "re re re re re" which is annoying and not very helpful).

(2) Also, would it be possible to ditch the multiple "RE:" prefixes? It just makes the comment list hard to read and I don't like it. One "RE:" is fine, but more than one is a waste.

(3) Finally, when the article name is very long, can the default comment subject be optionally set to drop everything after 25 characters? So for example when someone replies to my article "Frozen Martian Sea Discovered and Other Science News", the default comment title which appears on the comment form would be:

"Re: Frozen Martian Sea Discov..."

It seems to me that I ought to be able to make (2) and (3) happen via javascript. Yes?

(4) I would really like to offer an RSS feed for my comments. Is there any way to do that yet with blogware?

Thanks in advance for your advice!
_________________
-- Abacquer, A.K.A. Chuck Seggelin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Mon Mar 07, 2005 9:12 pm    Post subject: Re: More info in Recent Comments & Better Default Commen Reply with quote

Here is the code for the standard Recent Comments component:

Code:
{{if blog.recent_comments}}
<div class="component">
<div class="componentHead">Recent Comments</div>
<div class="componentContent">
<div class="componentRecentComments">
{{loop name=blog.recent_comments limit=5}}
<div class="componentRecentCommentsItem">
<a href="{{permalink_url}}">{{if title}}{{title}}{{else}}Untitled{{/if}}</a>
</div>
{{/loop}}
</div> <!-- componetRecentComments -->
</div> <!-- componentContent -->
</div> <!-- component -->
{{/if}} <!-- blog.recent_comments -->


You can customize the component using any of the following variables:
  • author The comment author (optional)
  • body The comment's body
  • can_post A boolean variable which indicates whether the current user can post a reply to this article
  • permalink_url The url to view this comment
  • post_reply_url The url which brings up the post-comment form
  • publish_time The publish time for the comment
  • thread_ends A loop whose size is equal to the number of indent levels that should be closed after this comment
  • thread_starts A loop whose size is equal to the number of indent levels that should be created for this comment
  • title The comment title
  • view_user_url The url to view author information
For example, the following would output the Recent Comments with the linked title on one line, and a byline and date (by Commenter at 2005.03.07 04:24PM PST) on the next line with the author linked to a popup window showing their profile page:

Code:
{{if blog.recent_comments}}
<div class="component">
<div class="componentHead">Recent Comments</div>
<div class="componentContent">
<div class="componentRecentComments">
{{loop name=blog.recent_comments limit=5}}
<div class="componentRecentCommentsItem">
<a href="{{permalink_url}}">{{if title}}{{title}}{{else}}Untitled{{/if}}</a>
</div>
<!--begin new additions-->
<div>
{{if author}}
    by <a href="javascript:openWindow('{{view_user_url}}', 'info', 450, 600);">{{var name=author escape=html}}</a> at {{publish_time}}
{{else}}
   by Anonymous at {{publish_time}}
{{/if}}
<!--end new additions-->
</div>
{{/loop}}
</div> <!-- componetRecentComments -->
</div> <!-- componentContent -->
</div> <!-- component -->
{{/if}} <!-- blog.recent_comments -->


Let's rearrange that to display according to your preference of having the content displayed in this order:

03/02/05 Darryl: Re: Re: thing

and use the additional time variables listed on this page to further customize the way the date is displayed instead of using the standard publish_time variable:

Code:
{{if blog.recent_comments}}
<div class="component">
<div class="componentHead">Recent Comments</div>
<div class="componentContent">
<div class="componentRecentComments">
{{loop name=blog.recent_comments limit=5}}
<div class="componentRecentCommentsItem">
{{publish_time.year}}/{{publish_time.month}}/{{publish_time.day}}:
{{if author}}
    <a href="javascript:openWindow('{{view_user_url}}', 'info', 450, 600);">{{var name=author escape=html}}</a>
{{else}}
   Anonymous
{{/if}}:
<a href="{{permalink_url}}">{{if title}}{{title}}{{else}}Untitled{{/if}}</a>
</div>
{{/loop}}


Also, would it be possible to ditch the multiple "RE:" prefixes? It just makes the comment list hard to read and I don't like it. One "RE:" is fine, but more than one is a waste.

We'll take that as a feature request...

Finally, when the article name is very long, can the default comment subject be optionally set to drop everything after 25 characters? So for example when someone replies to my article "Frozen Martian Sea Discovered and Other Science News", the default comment title which appears on the comment form would be:

And that as well.

It seems to me that I ought to be able to make (2) and (3) happen via javascript. Yes?

Might be possible, but I personally don't know how...

I would really like to offer an RSS feed for my comments. Is there any way to do that yet with blogware?

No, there is not. We do however offer email notifications for commenting.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abacquer



Joined: 22 Mar 2004
Posts: 193

PostPosted: Mon Mar 07, 2005 11:13 pm    Post subject: Reply with quote

Thanks John, I'll adapt that to my blog! Thanks for the great help!

I'll have to think about the comment subject default.

I know I can write the javascript to manipulate the string that appears in the field. The problem is getting that javascript to trigger. It's something I would want to happen on page load. However I would need access to the "BODY" tag to make that happen, and further the field would have to have an ID so that I could grab it with getElementByID. Hmm. I'll think about it. I may be able to finagle something. If I come up with an answer, I'll post it here.
_________________
-- Abacquer, A.K.A. Chuck Seggelin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abacquer



Joined: 22 Mar 2004
Posts: 193

PostPosted: Tue Mar 08, 2005 1:03 am    Post subject: Reply with quote

Using your code as a guide, I've reformatted my recent comments list. This is MUCH better! Thanks John! Very Happy
_________________
-- Abacquer, A.K.A. Chuck Seggelin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abacquer



Joined: 22 Mar 2004
Posts: 193

PostPosted: Tue Mar 08, 2005 4:32 am    Post subject: Re: More info in Recent Comments & Better Default Commen Reply with quote

abacquer wrote:
(2) Also, would it be possible to ditch the multiple "RE:" prefixes? It just makes the comment list hard to read and I don't like it. One "RE:" is fine, but more than one is a waste.

(3) Finally, when the article name is very long, can the default comment subject be optionally set to drop everything after 25 characters? So for example when someone replies to my article "Frozen Martian Sea Discovered and Other Science News", the default comment title which appears on the comment form would be:

"Re: Frozen Martian Sea Discov..."

It seems to me that I ought to be able to make (2) and (3) happen via javascript. Yes?


I figured this out though my solution is a little hokey. A cleaner solution would be to perhaps modify my article template, but since I would have to transplant all the code out of inline_comment_post.html into the staging area just so I can add one tiny javascript call, I decided to do it this clunkier way.

Here's what I did, first I wrote up the javascript that would fix the field value:

Code:
function adjustCommentDefaultSubject()
{
var inputs = document.getElementsByTagName("input");

var commentTitle = null;

for (var i=0; i<inputs.length; i++)
 {
  var inp = inputs[i];
  if (inp.name == "title")
  {
   commentTitle = inp;
   break;
  }
 }

 if (commentTitle != null)
 {
  var titleText = commentTitle.value;
   
  if ((titleText != "") && (titleText != null))
  {

   // remove extra re:'s
   while (titleText.substring(0,8).toLowerCase() == "re: re: ")
   {
    titleText = titleText.substring(4);
   }
   
   // shorten
   
   if (titleText.length > 30)
   {
    titleText = titleText.substring(0,27) + "...";
   }
   
   commentTitle.value = titleText;
  }
 }
}


This goes hunting for an INPUT tag with the name "title" (which is what the name of the comment title input tag is), and when it finds it, it shaves off any "Re: " prefixes more than one, then it checks the title length and if it is more than 30 characters, it chops off everything after char 27 and adds three periods to signify that the comment title has been shortened.

Now all I have to do is make it run, which turned out to be trickier than you might think. I don't have access to the <BODY> tag, so I had to put the onload call somewhere else. So I put it on the image in my BlogName component:

Code:
<div class="component">
<div class="componentBlogname">
<a href="{{blog.url}}"><img src="/banners/unbecoming_levity.gif" onload="setTimeout('adjustCommentDefaultSubject(),1500)"></a></div>
</div>


Originally I tried it without the timeout. This worked some of the time, except that the image might load before the comment form does, in which case it won't see the input tag when it goes looking. I added the timeout to give the page an extra 1.5 seconds to get loaded before the script goes looking for the comment field to fix. It works pretty good.[/code]
_________________
-- Abacquer, A.K.A. Chuck Seggelin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
john
Site Admin


Joined: 16 Mar 2004
Posts: 3434

PostPosted: Tue Mar 08, 2005 9:50 am    Post subject: Re: More info in Recent Comments & Better Default Commen Reply with quote

Killer stuff, Abacquer. Really awesome stuff.

I see you added your Javascript functions as an external file. That's probably the best way to do it for performance reasons, I would also like to point out that you can add Javascript functions to your blog as part of the HEAD of your HTML document using this feature of our system.

I added your Javascript function using the above feature by wrapping it up as follows:

Code:
<script type="text/javascript">
<!--
function adjustCommentDefaultSubject()
{
var inputs = document.getElementsByTagName("input");

var commentTitle = null;

for (var i=0; i<inputs.length; i++)
 {
  var inp = inputs[i];
  if (inp.name == "title")
  {
   commentTitle = inp;
   break;
  }
 }

 if (commentTitle != null)
 {
  var titleText = commentTitle.value;
   
  if ((titleText != "") && (titleText != null))
  {

   // remove extra re:'s
   while (titleText.substring(0,8).toLowerCase() == "re: re: ")
   {
    titleText = titleText.substring(4);
   }
   
   // shorten
   
   if (titleText.length > 30)
   {
    titleText = titleText.substring(0,27) + "...";
   }
   
   commentTitle.value = titleText;
  }
 }
}
//-->
</script>


and adding it into the HEAD area of the HTML.

I don't have access to the <BODY> tag, so I had to put the onload call somewhere else.

Actually you do, though your workaround was inventive. You can modify the BODY tag (and a whole lot of other stuff) by modifying the base template. Here's how to modify your base template::
  1. Login to your Blog Admin Control Panel through the Login page.
  2. Click on the Look and Feel tab, then the Templates subtab.
  3. Now you see a list of the Templates you can customize. We're going to customize the base template, which controls the overall structure of your blog pages, so click Edit in the row that begins with the word base.
  4. You'll be presented with a page listing the current templates (there will probably be only one row listing Standard), click the Customize button.
  5. You'll see a page giving you the option to Copy the Standard style to your staging area. Click Go.
  6. Finally, you'll come to the page where you can customize the base template, which is the template controlling the main structure of your page.
What I did was to add modify the BODY tag as follows:

Code:
<body onload="adjustCommentDefaultSubject()">


There you go, I think it's just what you were looking for. Or damn close anyway. Nice work, thanks for sharing your code. This is a great mod...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abacquer



Joined: 22 Mar 2004
Posts: 193

PostPosted: Tue Mar 08, 2005 6:09 pm    Post subject: Reply with quote

Thanks John for showing me how to get access to my <BODY> tag. That's great! I moved the call there and now there is no need for a hokey sometimes-doesn't-work timeout.

Now all my comment subjects are slim ... without zillions of RE's and having names that tell enough to figure out what the article was.

And nicely, if the user wants to modify the comment subject they can. As it was, if they started typing in the comment title field before the timer went off, the content could suddenly change on them.

This is much better.
_________________
-- Abacquer, A.K.A. Chuck Seggelin
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Search all BlogHarbor support resources.
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    BlogHarbor Community Forum Index -> General Discussion All times are GMT - 5 Hours
Page 1 of 1

 
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