1
noo-b
xoopspolls - show total comment in block
  • 2007/12/26 4:19

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


how do i do this
I Love Xoops

2
wizanda
Re: xoopspolls - show total comment in block
  • 2007/12/26 10:55

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


You can show the total comments for the site in a block, yet unsure if the comments for just the polls is possible.....without hacking it to do so......

3
noo-b
Re: xoopspolls - show total comment in block
  • 2007/12/26 12:11

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


i mean the total comment of a poll in the poll block

i want to put it below the vote button if possible
I Love Xoops

4
wizanda
Re: xoopspolls - show total comment in block
  • 2007/12/26 12:27

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


You could just add the Comments code from the template xoopspoll_results to the xoopspoll_view....
<div style="margin:3px; padding: 3px;">

<{if 
$comment_mode == "flat"}>
<{
includeq file="db:system_comments_flat.tpl"}>
<{elseif 
$comment_mode == "thread"}>
<{
includeq file="db:system_comments_thread.tpl"}>
<{elseif 
$comment_mode == "nest"}>
<{
includeq file="db:system_comments_nest.tpl"}>
<{/if}>

div>

Then update the module.....

5
noo-b
Re: xoopspolls - show total comment in block
  • 2007/12/26 12:56

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


i think you misunderstood me
i want it in xoopspoll_block_poll.html

example
Quote:

comments(2)
I Love Xoops

6
iHackCode
Re: xoopspolls - show total comment in block

you could.

modify xoopspoll_block_poll.html
(added a line for the comments. below the line for the vote button)
<td class="foot" align="center" colspan="2"><input type="submit" value="<{$block.lang_vote}>" /> <input type="button" value="<{$block.lang_results}>" onclick="location='<{$xoops_url}>/modules/xoopspoll/pollresults.php?poll_id=<{$poll.id}>'" />td>
  tr>
      <
tr><td class="foot" align="center" colspan="2"><b>Comments (<{$poll.comments}>)b>td>tr>


add a function in the xoopspoll class in the xoopspoll.php file in the module's class folder.
function getcomments($poll_id){
        
$db =& Database::getInstance();
        global 
$module_handler;
        
$pollmod $module_handler->getByDirname('xoopspoll');
        
$sql"SELECT count(com_id) FROM ".$db->prefix('xoopscomments')." WHERE com_modid = '".$pollmod->getVar('mid')."' AND com_itemid = '".$poll_id."'";
        
$result $db->query($sql);
        while (
$row $db->fetchArray($result)) {
            
$amt=$row['count(com_id)'];
        }
        unset(
$pollmod);
        return 
$amt;
    }


and then modify the XOOPS poll block in the blocks/xoopspoll.php file. in the module's folder
.modified the line below so it sets a value for our comments variable.
$poll = array('id' => $polls[$i]->getVar('poll_id'), 'comments' => XoopsPoll::getcomments($polls[$i]->getVar('poll_id')),'question' => $polls[$i]->getVar('question'), 'option_type' => $option_type'option_name' => $option_name'options' => $options);


and that should work.. (do a module update so the system can update the block's template file.)
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

7
belia
Re: xoopspolls - show total comment in block
  • 2007/12/26 19:50

  • belia

  • Just popping in

  • Posts: 83

  • Since: 2007/12/18


how to implement this in the umfrage module ?

8
noo-b
Re: xoopspolls - show total comment in block
  • 2007/12/27 3:09

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


thank you banditx

have you tested this yourself ?

i got this message

Fatal error: Call to a member function getByDirname() on a non-object in ...\modules\xoopspoll\class\xoopspoll.php on line 68


Quote:

Bandit-X wrote:
you could.

add a function in the xoopspoll class in the xoopspoll.php file in the module's class folder.
function getcomments($poll_id){
        
$db =& Database::getInstance();
        global 
$module_handler;
        
$pollmod $module_handler->getByDirname('xoopspoll');
        
$sql"SELECT count(com_id) FROM ".$db->prefix('xoopscomments')." WHERE com_modid = '".$pollmod->getVar('mid')."' AND com_itemid = '".$poll_id."'";
        
$result $db->query($sql);
        while (
$row $db->fetchArray($result)) {
            
$amt=$row['count(com_id)'];
        }
        unset(
$pollmod);
        return 
$amt;
    }


After which line actually do i have to put this code ?
I Love Xoops

9
iHackCode
Re: xoopspolls - show total comment in block

use this in the class. (i put it after the getall method. but you can put it anywhere inside the class. just make sure it is not inside another function)

this one works with 2.0.17.1
function getcomments($poll_id){
        
$db =& Database::getInstance();
        
$module_handler xoops_gethandler("module"); 
        
$pollmod $module_handler->getByDirname('xoopspoll');
        
$sql"SELECT count(com_id) FROM ".$db->prefix('xoopscomments')." WHERE com_modid = '".$pollmod->getVar('mid')."' AND com_itemid = '".$poll_id."'";
        
$result $db->query($sql);
        while (
$row $db->fetchArray($result)) {
            
$amt=$row['count(com_id)'];
        }
        unset(
$pollmod);
        return 
$amt;
    }


im not sure with umfrage. i will have to check it tomorrow.
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

10
noo-b
Re: xoopspolls - show total comment in block
  • 2007/12/27 5:39

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


my main page went blank like previously and i turn on the debug

i still got the same message

Fatal error: Call to a member function getByDirname() on a non-object in ..modules\xoopspoll\class\xoopspoll.php

i've updated the module, cleared templates_c

im using 2.0171 and xoopspoll 1.02 (php5)
http://www.xoopsaddons.org/modules/wfdownloads/singlefile.php?lid=1241
I Love Xoops

Login

Who's Online

322 user(s) are online (265 user(s) are browsing Support Forums)


Members: 0


Guests: 322


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