1
jonyk
Custom Block which calls a function from an include file
  • 2006/11/9 0:49

  • jonyk

  • Just popping in

  • Posts: 4

  • Since: 2006/11/9


I created a custom block with code:
require('\test_lib.php');
test();

the test_lib.php:
<?
function test()
{
echo "testing...";
}
?>

Amazingly the output complaining that test() is not defined. I dont' get it.

Another funny thing is that if I wrap my custom block code into its own php file for example wrapper.php, then in the custom block,i wrote:
require('wrapper.php');
then the code works.

The problem is that my ISP disallow the 2nd option.

Anyone has any clues?

Thanks.

2
m0nty
Re: Custom Block which calls a function from an include file
  • 2006/11/9 0:58

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


make sure you tick the box that says php code or whatever.

and don't use the open/close tags <? ?>

also, get used to using long tag like <?php instead of short tag <? it's better practice, as sometimes short tags can be disabled in php.ini

eitherway tho, when pasting code into the blocks either select html or php but don't use the tags.. as XOOPS does it for you.

3
jonyk
Re: Custom Block which calls a function from an include file
  • 2006/11/9 2:18

  • jonyk

  • Just popping in

  • Posts: 4

  • Since: 2006/11/9


Thanks for your reply m0nthy.

I did all what u said but problem still persist.

I wonder if include/require in custom block does not actually means including the file like normal php file?

Thanks.

4
m0nty
Re: Custom Block which calls a function from an include file
  • 2006/11/9 2:22

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


it should do, i've used include statements in custom blocks before..

try using an absolute path in the include, instead of a relative path.

5
jonyk
Re: Custom Block which calls a function from an include file
  • 2006/11/9 2:29

  • jonyk

  • Just popping in

  • Posts: 4

  • Since: 2006/11/9


I have also tried using absolute path, but still in vain.

Did you also call a function from the include?
I think include is working, just that you can't call the function from the include file.

6
m0nty
Re: Custom Block which calls a function from an include file
  • 2006/11/9 2:52

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


no don't think i called a function from the block itself.

why does your ISP not allow you to use the require (2nd option) i can't see any reason for them to disallow it, the whole XOOPS system works like that.

7
jonyk
Re: Custom Block which calls a function from an include file
  • 2006/11/9 3:19

  • jonyk

  • Just popping in

  • Posts: 4

  • Since: 2006/11/9


This is what I got if I use the 2nd option:
Warning [PHP]: Unknown(): URL file-access is disabled in the server configuration in file /home/mypage/public_html/html/class/xoopsblock.php(146) : eval()'d code line 7
Warning [PHP]: Unknown(http://www.mypage.com/html/test_special.php): failed to open stream: no suitable wrapper could be found in file /home/mypage/public_html/html/class/xoopsblock.php(146) : eval()'d code line 7
Warning [PHP]: (null)(): Failed opening 'http://www.mypage.com/html/test_special.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in file /home/mypage/public_html/html/class/xoopsblock.php(146) : eval()'d code line 7

Not sure why my ISP disable it tough =).

Login

Who's Online

157 user(s) are online (95 user(s) are browsing Support Forums)


Members: 0


Guests: 157


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