1
sato-san
system_block_comments.html change
  • 2007/6/13 12:08

  • sato-san

  • Quite a regular

  • Posts: 224

  • Since: 2005/7/1 1


Hello,

I would like to change my templetes of "system_block_comments.html". I would like to indicate also the Comment-text and also the picture of the user.

That is my source:
Quote:


<{foreach item=comment from=$block.comments}>
">






<{/foreach}>
<{if $comment.poster.id != 0}><{/if}> <{$comment.title}>
<{$comment.text}>
<{$comment.text}>
<{$comment.poster.uname}>



Im can see only the "<{$comment.title}>".
Why?

2
rplima2004
Re: system_block_comments.html change
  • 2007/6/13 13:27

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


Hi René,

Looking at the php code (modules/system/blocks/system_blocks.php) of the block (xoops 2016) I noticed that in the construction of the block only exist the poster name, uid, comment title, icon and time.

To show the other information that you desires would be necessary to include them in the function (b_system_comments_show).

3
rplima2004
Re: system_block_comments.html change
  • 2007/6/13 13:46

  • rplima2004

  • Just popping in

  • Posts: 70

  • Since: 2004/10/8


René,

The original code of the function is:
function b_system_comments_show($options)
{
    
$block = array();
    include_once 
XOOPS_ROOT_PATH.'/include/comment_constants.php';
    
$comment_handler =& xoops_gethandler('comment');
    
$criteria = new CriteriaCompo(new Criteria('com_status'XOOPS_COMMENT_ACTIVE));
    
$criteria->setLimit(intval($options[0]));
    
$criteria->setSort('com_created');
    
$criteria->setOrder('DESC');
    
$comments $comment_handler->getObjects($criteriatrue);
    
$member_handler =& xoops_gethandler('member');
    
$module_handler =& xoops_gethandler('module');
    
$modules $module_handler->getObjects(new Criteria('hascomments'1), true);
    
$comment_config = array();
    foreach (
array_keys($comments) as $i) {
        
$mid $comments[$i]->getVar('com_modid');
        
$com['module'] = '.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'';
        if (!isset(
$comment_config[$mid])) {
            
$comment_config[$mid] = $modules[$mid]->getInfo('comments');
        }
        
$com['id'] = $i;
        
$com['title'] = '.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'';
        
$com['icon'] = htmlspecialchars$comments[$i]->getVar('com_icon'), ENT_QUOTES );
        
$com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
        
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
        if (
$comments[$i]->getVar('com_uid') > 0) {
            
$poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
            if (
is_object($poster)) {
                
$com['poster'] = '.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'';
            } else {
                
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
            }
        } else {
            
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
        }
        
$block['comments'][] =& $com;
        unset(
$com);
    }
    return 
$block;
}


Change to this:
function b_system_comments_show($options)
{
    
$block = array();
    include_once 
XOOPS_ROOT_PATH.'/include/comment_constants.php';
    
$comment_handler =& xoops_gethandler('comment');
    
$criteria = new CriteriaCompo(new Criteria('com_status'XOOPS_COMMENT_ACTIVE));
    
$criteria->setLimit(intval($options[0]));
    
$criteria->setSort('com_created');
    
$criteria->setOrder('DESC');
    
$comments $comment_handler->getObjects($criteriatrue);
    
$member_handler =& xoops_gethandler('member');
    
$module_handler =& xoops_gethandler('module');
    
$modules $module_handler->getObjects(new Criteria('hascomments'1), true);
    
$comment_config = array();
    foreach (
array_keys($comments) as $i) {
        
$mid $comments[$i]->getVar('com_modid');
        
$com['module'] = '.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'';
        if (!isset(
$comment_config[$mid])) {
            
$comment_config[$mid] = $modules[$mid]->getInfo('comments');
        }
        
$com['id'] = $i;
        
$com['title'] = '.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'';
        
$com['text'] = $comments[$i]->getVar('com_text');
        
$com['icon'] = htmlspecialchars$comments[$i]->getVar('com_icon'), ENT_QUOTES );
        
$com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
        
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
        if (
$comments[$i]->getVar('com_uid') > 0) {
            
$com['poster'] = array();
            
$poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
            if (
is_object($poster)) {
                
$com['poster']['link'] = '.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'';
                
$com['poster']['id'] = $comments[$i]->getVar('com_uid');
                
$com['poster']['uname'] = $poster->getVar('uname');
                
$com['poster']['avatar'] = '.XOOPS_URL.'/uploads/'.$poster->getVar('user_avatar').'" />';  
            } else {
                
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
            }
        } else {
            
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
        }
        
$block['comments'][] =& $com;
        unset(
$com);
    }
    return 
$block;
}


Now it's only to use in templates the new variables.

< {$comment.poster.link}>
< {$comment.poster.uid}>
< {$comment.poster.uname}>
< {$comment.poster.avatar}>
< {$comment.text}>

I hope that it helps you

Rodrigo

4
sato-san
Re: system_block_comments.html change
  • 2007/6/13 16:52

  • sato-san

  • Quite a regular

  • Posts: 224

  • Since: 2005/7/1 1


Thanks for your fast assistance. I use the XOOPS 2.2.x for this project however I your information to use will be able. Thanks.

5
sato-san
Re: system_block_comments.html change
  • 2007/6/14 12:41

  • sato-san

  • Quite a regular

  • Posts: 224

  • Since: 2005/7/1 1


Very well, I changed it for XOOPS 2,2 and functioned. Can you extend that for a further function? I need still another link (URL) for the comment.

ex.
< {$comment.link}>

And im would linke a Klon from this Block however with another layout. Is also possible?



Thank you !!!

6
sato-san
Re: system_block_comments.html change
  • 2007/6/18 9:10

  • sato-san

  • Quite a regular

  • Posts: 224

  • Since: 2005/7/1 1


BIG THANKS for helping! Now works great. I which important in addition learned.

7
giba
Re: system_block_comments.html change
  • 2007/6/18 9:33

  • giba

  • Just can't stay away

  • Posts: 638

  • Since: 2003/4/26


Hi René, what?s end (final) soluction ?

You have one screenShot example ?

Thanks

8
sato-san
Re: system_block_comments.html change
  • 2007/6/18 11:46

  • sato-san

  • Quite a regular

  • Posts: 224

  • Since: 2005/7/1 1


Hi Giba,

The project is not yet completely finished. @Alfred builds still blocks for the footer area in simple XOOPS (as with XOOPS 2.0.16). Preview gives it here:
http://scrumeducations.sprint-it.com

Clones of a block is very simple. For example - Provide from a comment block:
Edit your /modules/system/xoops_version.php

copy the line (164-170 ???)
Quote:

$modversion['blocks'][10]['file'] = "system_blocks.php";
$modversion['blocks'][10]['name'] = _MI_SYSTEM_BNAME11;
$modversion['blocks'][10]['description'] = "Shows most recent comments";
$modversion['blocks'][10]['show_func'] = "b_system_comments_show";
$modversion['blocks'][10]['options'] = "10";
$modversion['blocks'][10]['edit_func'] = "b_system_comments_edit";
$modversion['blocks'][10]['template'] = 'system_block_comments.html';


search the latest blocknumber (ex. 13)
add the same with new blocknumber and rename the blockname: ex.
Quote:

$modversion['blocks'][14]['file'] = "system_blocks.php";
$modversion['blocks'][14]['name'] = _MI_SYSTEM_BNAME11;
$modversion['blocks'][14]['description'] = "Shows most recent comments";
$modversion['blocks'][14]['show_func'] = "b_system_comments_show";
$modversion['blocks'][14]['options'] = "10";
$modversion['blocks'][14]['edit_func'] = "b_system_comments_edit";
$modversion['blocks'][14]['template'] = 'system_block_comments_block_number_two.html';

add a new template with the new blockname: system_block_comments_block_number_two.html

copy this files via FTP and update the system modul, now you have a new template. If you have a klon of you template, then you can change the code of from the block system_block_comments_block_number_two

Very Easy.


And in this block im have now more extensions to show in this block. (Thanks to Rodrigo!)
Edit the modules/system/block/system_blocks.php and change the "function b_system_comments_show" to:

Quote:

.
.
.
foreach (array_keys($comments) as $i) {
$mid = $comments[$i]->getVar('com_modid');
$com['module'] = ''.$modules[$mid]->getVar('name').'';
if (!isset($comment_config[$mid])) {
$comment_config[$mid] = $modules[$mid]->getInfo('comments');
}
$com['id'] = $i;
$com['title'] = ''.$comments[$i]->getVar('com_title').'';
$com['text'] = $comments[$i]->getVar('com_text');
$com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES );
$com['icon'] = ($com['icon'] != '') ? "subject/".$com['icon'] : 'subject/icon1.gif';
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
$com['link'] = '[de]Mehr[/de][en]More[/en]...';
if ($comments[$i]->getVar('com_uid') > 0) {
$com['poster'] = array();
$poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
if (is_object($poster)) {
$com['poster']['link'] = ''.$poster->getVar('uname').'';
$com['poster']['id'] = $comments[$i]->getVar('com_uid');
$com['poster']['uname'] = $poster->getVar('uname');
$com['poster']['avatar'] = '';
} else {
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
}
} else {
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
}
$block['comments'][] =& $com;
unset($com);
}
.
.
.


Now you can add in your templtes:
< {$comment.poster.link}>
< {$comment.poster.uid}>
< {$comment.poster.uname}>
< {$comment.poster.avatar}>
< {$comment.text}>
< {$comment.link}>



9
Kieran
Re: system_block_comments.html change
  • 2007/10/12 10:51

  • Kieran

  • Just popping in

  • Posts: 32

  • Since: 2007/7/12


Hi there,

This is exactly what I want to do (actually just need to add the users avatar to each comment).

I've copied the above but it doesn't work - tried to figure out why but can't

Here's my code

Template:
Quote:

<{foreach item=comment from=$block.comments}>



<{/foreach}>
<{$comment.title}> Posted by <{$comment.poster}>


Systems Block:
Quote:

function b_system_comments_show($options)
{
$block = array();
include_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
$comment_handler =& xoops_gethandler('comment');
$criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
$criteria->setLimit(intval($options[0]));
$criteria->setSort('com_created');
$criteria->setOrder('DESC');
$comments = $comment_handler->getObjects($criteria, true);
$member_handler =& xoops_gethandler('member');
$module_handler =& xoops_gethandler('module');
$modules = $module_handler->getObjects(new Criteria('hascomments', 1), true);
$comment_config = array();
foreach (array_keys($comments) as $i) {
$mid = $comments[$i]->getVar('com_modid');
$com['module'] = ''.$modules[$mid]->getVar('name').'';
if (!isset($comment_config[$mid])) {
$comment_config[$mid] = $modules[$mid]->getInfo('comments');
}
$com['id'] = $i;
$com['title'] = ''.$comments[$i]->getVar('com_title').'';
$com['text'] = $comments[$i]->getVar('com_text');
$com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES );
$com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
if ($comments[$i]->getVar('com_uid') > 0) {
$com['poster'] = array();
$poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
if (is_object($poster)) {
$com['poster']['link'] = ''.$poster->getVar('uname').'';
$com['poster']['id'] = $comments[$i]->getVar('com_uid');
$com['poster']['uname'] = $poster->getVar('uname');
$com['poster']['avatar'] = '';
} else {
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
}
} else {
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
}
$block['comments'][] =& $com;
unset($com);
}
return $block;
}


Thanks for any help

Login

Who's Online

344 user(s) are online (206 user(s) are browsing Support Forums)


Members: 0


Guests: 344


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits