1
WarDick
Fatal Error when calling load()
  • 2005/8/9 7:15

  • WarDick

  • Just can't stay away

  • Posts: 890

  • Since: 2003/9/13


My favorite module wiwimod no longer works in 2.2.1. One of the most powerful features of wiwimod, the ability to place anyblock anywhere no longer works. It uses a function called load(). Has this function been removed in this version. If so is there a work around? If no can I get some help getting it to work?
Urging XOOPS to be the Best It Can Be.
Richard......

2
Mithrandir
Re: Fatal Error when calling load()

Modules that mimic core functionality - such as block creation and placement - are very sensitive to changes in the core.

In XOOPS 2.2, we have reworked the blocks system so you can now instantiate as many of the same blocks as you want to. However, that is not surprisingly conflicting with wiwimod when it tries to work with the old database structure.

I don't know wiwimod and how it does this block placement, so I cannot say how you can get it to work.
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

3
WarDick
Re: Fatal Error when calling load()
  • 2005/8/9 8:15

  • WarDick

  • Just can't stay away

  • Posts: 890

  • Since: 2003/9/13


It passes a block id or name to a function called load.

Is this function no longer available?

The error message is Fatal error: Call to undefined function: load() in /home/modules/wiwimod/include/functions.php on line 50

Thank you for the information.
Urging XOOPS to be the Best It Can Be.
Richard......

4
Mithrandir
Re: Fatal Error when calling load()

XOOPS core has not and never (at least not recently) had any function called load()

Is it a class method? On what kind of object?
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

5
WarDick
Re: Fatal Error when calling load()
  • 2005/8/9 8:31

  • WarDick

  • Just can't stay away

  • Posts: 890

  • Since: 2003/9/13


I am sorry I do not know the answer to your question.

Here is the code:Quote:
function wiwimod_getXoopsBlock ($blkname) { // block title or id
global $xoopsUser;
global $xoopsDB;

$block = array();
$bcontent = "";
$bid = intval($blkname);

//
// check block to show
//
$blk = new XoopsBlock;
if ($bid == 0) {
$blklst = $blk->getAllBlocks();
foreach ($blklst as $b) {
if (strcasecmp($b->getVar('title'), $blkname) == 0) {
$bid = $b->getVar('bid');
break;
}
}
}

//
// build block and extract content
//
if ($bid > 0) {
$blk->load($bid);

$btpl = $blk->getVar('template');
$bid = $blk->getVar('bid');
$bresult =& $blk->buildBlock();
if ($bresult) {
require_once XOOPS_ROOT_PATH.'/class/template.php';
$xoopsTpl = new XoopsTpl();
$xoopsTpl->xoops_setCaching(2);

if ($btpl != '') {
$xoopsTpl->assign_by_ref('block', $bresult);
$bcontent =& $xoopsTpl->fetch('db:'.$btpl);
$xoopsTpl->clear_assign('block');
} else {
$xoopsTpl->assign_by_ref('dummy_content', $bresult['content']);
$bcontent =& $xoopsTpl->fetch('db:system_dummy.html', 'blk_'.$bid);
$xoopsTpl->clear_assign('dummy_content');
}
}
}
$block['content'] = $bcontent;

return $block;
}

//ok >> rename to render_block


It fails on the line in red.
Urging XOOPS to be the Best It Can Be.
Richard......

6
skalpa
Re: Fatal Error when calling load()
  • 2005/8/9 9:06

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


Quote:
XOOPS core has not and never (at least not recently) had any function called load()


Well, that's not what the /class/xoopsblock.php file of XOOPS 2.0.13 indicates.

Wardick: yes it disappeared, and it's mainly due to the fact blocks have become duplicatable, but do not have any way of being configured so "default parameters" are specified (and the load method did expect the block it was inserting to have been formerly configured in the admin).
Now the point is that it's not easy to fix, and that this particular problem does not concern many modules.
So we are going to investigate this, but can't promise the method is coming back. Maybe the solution will happen to be a future wiwimod update, with this particular feature being enhanced and using the possibilities of the new system.

skalpa.>
Any intelligent fool can make things bigger, and more complex. It takes a touch of genius, a lot of courage, to move in the opposite direction.
Two things are infinite: the universe and human stupidity; and I'm not sure about the 1st one (A.Einstein)

7
Mithrandir
Re: Fatal Error when calling load()

See if this changes anything

function wiwimod_getXoopsBlock ($blkname) {  // block title or id
    
global $xoopsUser;
    global 
$xoopsDB;

    
$block = array();
    
$bcontent "";
    
$bid intval($blkname);

    
// 
    // check block to show
    //
        
$blk_handler xoops_gethandler('blockinstance');

    if (
$bid == 0) {
                
$criteria = new Criteria('title'$blkname"LIKE");
        
$b $blk_handler->getObjects($criteria);
                if (
is_object($b[0])) {
                    
$bid $b[0]->getVar('bid');
        }
    }

    
//
    // build block and extract content
    //
    
if ($bid 0) {
                
$blk $blk_handler->get($bid);

        
$btpl $blk->block->getVar('template');
        
$bid $blk->getVar('bid');
        
$bresult =& $blk->buildBlock();
        if (
$bresult) {
            require_once 
XOOPS_ROOT_PATH.'/class/template.php';
            
$xoopsTpl = new XoopsTpl();
            
$xoopsTpl->xoops_setCaching(2);
            
            if (
$btpl != '') {
                
$xoopsTpl->assign_by_ref('block'$bresult);
                
$bcontent =& $xoopsTpl->fetch('db:'.$btpl);
                
$xoopsTpl->clear_assign('block');
            } else {
                
$xoopsTpl->assign_by_ref('dummy_content'$bresult['content']);
                
$bcontent =& $xoopsTpl->fetch('db:system_dummy.html''blk_'.$bid);
                
$xoopsTpl->clear_assign('dummy_content');
            }
        }
    }
    
$block['content'] = $bcontent;

    return 
$block;
}

//ok >> rename to render_block
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

8
Mithrandir
Re: Fatal Error when calling load()

Quote:
Well, that's not what the /class/xoopsblock.php file of XOOPS 2.0.13 indicates.

That file has a function called load()?
As I read it, it is a class method and not a function and I was trying to determine whether it was a XOOPS or wiwi function or method.
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

9
WarDick
Re: Fatal Error when calling load()
  • 2005/8/9 9:37

  • WarDick

  • Just can't stay away

  • Posts: 890

  • Since: 2003/9/13


@ skalpa
Thank you for the information. Wiwimod is such a powerful module I hope we can get it 100% functional.

@ mith
Thank you for the code. I did not work but gave this new error message.

Fatal error: Call to a member function on a non-object in /home/kinneyco/public_html/kcgcd/modules/wiwimod/include/functions.php on line 51
Urging XOOPS to be the Best It Can Be.
Richard......

10
Xavier
Re: Fatal Error when calling load()
  • 2005/10/8 8:45

  • Xavier

  • Just popping in

  • Posts: 38

  • Since: 2004/5/12


Hi ; i've just discovered this thread; here is a quick workaround for 2.2 version, that WON'T WORK WITH PREVIOUS VERSIONS of Xoops.
Meanwhile, i'll study Mith's code : you always learn from masters . By the way Mith, this new blocks implementation rocks !

Replace function "wiwimod_getXoopsBlock" in file wiwimod/include/functions.php with the following updated code :
//
// adapted for XOOPS 2.2 from function assignBlocks() in file kernel/block.php
// TODO : backwards compatibility for XOOPS 2.1.x and lower
//
function wiwimod_getXoopsBlock ($blkname) {  // block title or id
    
    
global $xoopsUser$block_handler$xoopsModule$xoopsTpl;

    
$groups $xoopsUser $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;  
    
$modulepage $xoopsModule->getCurrentPage();
    
$block_arr =& $block_handler->getAllByGroupModule($groups,$modulepage["mid"], $modulepage["page"]);  // returns block instances
    
$block_info = array('content' => "TEST");
    
//
    // Find the relevant block instance
    //
    
foreach (array_keys($block_arr) as $i) {
        if ((
strcasecmp($block_arr[$i]->getVar('title'), $blkname) == 0) || (intval($blkname) == $block_arr[$i]->getVar('instanceid'))) {
            
//
            // build the block or retrieve it from cache
            //
            
$bcachetime $block_arr[$i]->getVar('bcachetime');
            if (empty(
$bcachetime)) {
                
$xoopsTpl->xoops_setCaching(0);
            } else {
                
$xoopsTpl->xoops_setCaching(2);
                
$xoopsTpl->xoops_setCacheTime($bcachetime);
            }
            
$btpl $block_arr[$i]->block->getVar('template') != '' $block_arr[$i]->block->getVar('template') : "system_block_dummy.html";

            if (empty(
$bcachetime) || !$xoopsTpl->is_cached('db:'.$btpl'blk_'.$block_arr[$i]->getVar('instanceid'))) {
                
$bresult =& $block_arr[$i]->buildBlock();
                if (!
$bresult) {
                    break;
                }
                
$xoopsTpl->assign_by_ref('block'$bresult);
                
$bcontent =& $xoopsTpl->fetch('db:'.$btpl'blk_'.$block_arr[$i]->getVar('instanceid'));
                
$xoopsTpl->clear_assign('block');
            } else {
                
$bcontent =& $xoopsTpl->fetch('db:'.$btpl'blk_'.$block_arr[$i]->getVar('instanceid'));
            }

            
$block_info = array('title' => $block_arr[$i]->getVar('title'), 
                                
'content' => $bcontent
                                
'id' => $block_arr[$i]->getVar('instanceid'), 
                                
'typeid' => $block_arr[$i]->block->getVar('bid'), 
                                
'weight' => $block_arr[$i]->getVar('weight'));
            
            break;
        } 
    }
    return 
$block_info;
}

THIS CODE WILL NOT WORK WITH OLDER VERSIONS OF XOOPS

Xavier

Login

Who's Online

168 user(s) are online (108 user(s) are browsing Support Forums)


Members: 0


Guests: 168


more...

Donat-O-Meter

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

Latest GitHub Commits