View Full Version : Is it possible to show 'recent comments' in a sidebar box?
pcoskat
06-01-2007, 02:03 PM
Look at this site: http://www.livinginzen.net/
Notice how in the far RIGHT column, there is a 'recent comments' section?
Is it possible to do that in Vivvo? (instead of 'Most commented on')?
Yes, this is quite doable (just refer to How-To section on creating article lists). We'll see if we can find some time to post this mod.
pcoskat
06-01-2007, 03:59 PM
Brilliant - thank you.
Here is How-To for creating a box with most recent comments:
1. Create file recentComments.php in VIVVO_ROOT/include/box/
Put the following code in this file:
<?php
function recentComments($direction = 'descending', $limit = 10, $offset = 0, $box_title = 'Last comments'){
global $root, $tpl_folder, $lang, $cur_date;
$comments_list = new Comments_list();
$comments_list->search($params, 'id', $direction, $limit, $offset);
$filename = $root . '/templates/content/summary/comment_title.tpl';
$comments_string_template = file_get_contents($filename);
$pattern=array(
'{ROOT}',
'{ID}',
'{ARTICLE_ID}',
'{CREATED}',
'{DESCRIPTION}',
'{AUTHOR}',
'{EMAIL}',
'{IP}',
'{LINK}'
);
$comment_list_output = '';
foreach ($comments_list->list as $comment){
$replacement=array(
WP_URL,
$comment->id,
$comment->article_id,
vivvo_date($comment->create_dt, true),
$comment->description,
$comment->author,
$comment->email,
$comment->ip,
'index.php?news=' . $comment->article_id
);
$comment_list_output .= my_str_replace($pattern, $replacement, $comments_string_template);
}
$filename = $root . "/templates/content/box_comment_list.tpl";
$subject = file_get_contents($filename);
$pattern=array(
'{ROOT}',
'{BOX_TITLE}',
'{COMMENT_LIST}'
);
$replacement=array(
WP_URL,
$box_title,
$comment_list_output
);
$subject = my_str_replace($pattern, $replacement, $subject);
return $subject;
}
?>
2. Create 2 templates in templates directory.
First, create box_comment_list.tpl file in VIVVO_ROOT/templates/content/
and paste this code inside:
<div id="boc_last_comments" class="box_right">
<div class="box_title"><h3>{BOX_TITLE}</h3></div>
<div class="box_line">
</div>
<div class="box_body">
<ul>{COMMENT_LIST}</ul>
</div>
</div>
Next, create comment_title.tpl in VIVVO_ROOT/templates/content/summary/
and paste this code:
<li><a href="{ROOT}{LINK}">{DESCRIPTION}</a></li>
In comment_title.tpl you can use folowing tags:
{ROOT} - Url
{ID} - Comment id
{ARTICLE_ID} - Article id of comment
{CREATED} - Date and time of comment
{DESCRIPTION} - Comment description
{AUTHOR} - Author comment
{EMAIL} - Email of author
{IP} - Ip of comment
{LINK} - link for article of comment (example: index.php?news=1)
3. In box_definition.php file located in VIVVO_ROOT/include/ you need to assign the content:
Paste this code in the file (we recommend at the very end of file before '} ?>') :
$box_last_comments_HTML = recentComments('ascending', 2, 0, 'RECENT COMMENTS');
$template_manager->assign($box_last_comments_HTML,'/{BOX_RECENT_COMMENTS}/');
After that you can paste this tag {BOX_RECENT_COMMENTS} in any template where you want the recent comments to appear, i.e. index.tpl, or article_full.tpl
pcoskat
06-04-2007, 02:16 PM
LOVE IT! thank you for taking the time to post this code. Much appreciated!
apocan
06-04-2007, 03:11 PM
there is a problem $box_last_comments_HTML = recentComments('ascending', 2, 'RECENT COMMENTS');
in here..
shketuljko
06-04-2007, 04:12 PM
there is a problem
in here..
Yes, this function receive 4 arguments.
First argument is sort, second argument is limit, third argument is offest and fourth argument is box title.
You need to correct this line:
$box_last_comments_HTML = recentComments('ascending', 2, 0,'RECENT COMMENTS');
apocan
06-04-2007, 07:20 PM
I didnt understand... any example please..
krany
06-07-2007, 09:44 AM
How can I liit the number of words to show??? (If one message is too long it would make the page very large to scroll down)
pcoskat
07-18-2007, 04:25 PM
How can I liit the number of words to show??? (If one message is too long it would make the page very large to scroll down)
Any answers for ^this^?
Also, has anyone put this into action.
Now that my site as gone live, I can see where comments (similar to the link in the OP are really necessary on my new vivvo site.)
apocan
07-18-2007, 05:49 PM
I tried this but couldnt do and give up trying... If anyone can do please say us :) I want this feature..
apocan
07-19-2007, 11:58 PM
whatever I did, it didnt work in my site and an error occures in the box definition :( is there anyone who was able to do it?
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.