21
Coplan
Re: Blocks
  • 2004/5/13 3:54

  • Coplan

  • Just popping in

  • Posts: 51

  • Since: 2002/10/2


With that line in place, I get the following error on the blank screen (and only the following error, nothing else):

Quote:

Fatal error: Call to a member function on a non-object in /opt/devel/xoops/modules/tunetracker/system.php on line 13




BTW, here is a tarball holding my entire module. It's tunetracker/blocks/tt_blocks.php that I'm having trouble with:

www.scenespot.org/coplan/tunetracker.tar.gz


You'll notice that I have the mainfile.php include commented out in system.php. I doesn't seem to make a difference if that line is present or not.

Again, I thank you all for your patience and your help. I'll probably be kicking myself when I find out the real problem.


PS -- it's all a tiny bit messy at the moment. I fully intend to do things the XOOPS way and move as much as possible into the language files. I also intend to clean up some of my subroutines.

22
worlds
Re: Blocks - solved
  • 2004/5/13 20:32

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Got it.

And, in fine XOOPS tradition, I'll observe that you can find an explanation in the forums, at least a partial one,
here

But the core problem is that block code is not the same as module code. It's not running with the same context as module code (no $xoopsModule), and it is included from within a function, so the code in system.php that you THINK is at global scope, is really within a function.


So, to fix:
1) Take references to xoopsModule out of system.php, if you are going to include it from block code. (You don't use it there anyway)

2) Move ALL CODE in system.php into functions (which is a good idea anyway). That way you will realize you have to have all the needed "global" statements.

I'd actually like to see this changed in 2.07, as it adds a lot of confusion, and compicates code sharing, but that's another long post.

Tom
p.s. As a "quick fix", in system.php comment out the $mid line, and then add
global $xoopsDB;


Then once you see that it works better, go back and fix it right.

23
Coplan
Re: Blocks - solved
  • 2004/5/14 3:42

  • Coplan

  • Just popping in

  • Posts: 51

  • Since: 2002/10/2


So it seems my only problem was not fully understanding how the block functions worked.

As per your recommendation, I am working on cleaning out the non-function data within my system.php file. I was trying to make my code look a little cleaner by moving the table prefixing routines to some other place. I guess it caused more problems.

But, this is my first XOOPS modules, so I think I'm doing okay.

Thank you ALL for your patience. I now know what I did wrong, and I will work to become more xoops-like in my programming. I've learned a lot from this thread. Thanks again.

Login

Who's Online

212 user(s) are online (142 user(s) are browsing Support Forums)


Members: 0


Guests: 212


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