1
glypo
PHP Includes in blocks
  • 2006/10/2 23:35

  • glypo

  • Just popping in

  • Posts: 3

  • Since: 2006/10/1


After 2 days of searching this site and others I'm stumped.

I have created a PHP script that basically shuffles some images about on the web page. The main file should be included once and then my idea was to echo a variable in each block.

For example block1 would have:

include('thefile.php');
echo"$output1";

So this includes my script, then the other blocks would be

echo"$output2";

And so on, a different variable in each block. My script works perfectly on my website (http://www.glypo.co.uk/imageads4) however when I set it up in XOOPS (using blocks and selecting php as the type) the only block that works is the one with the include. And I tested this further by including the file in each block, this was the only way to get an output. However this messes up as my script as it should only be included once.

Any ideas why I can't pull out variables in one block if the file I include is in another block?

Perhaps there is somewhere else I can include my script so I can echo the variable in a block?

Thank you!

-----

XOOPS Version: 2.0.13.1
PHP Version: 4.x
Web Server Software: Apache
Operating System: Unix
Theme: Default
Custom template: No

2
Shelia
Re: PHP Includes in blocks
  • 2006/10/3 2:30

  • Shelia

  • Not too shy to talk

  • Posts: 140

  • Since: 2003/6/22


Includes seem only to work if files are relative to the XOOPS root

Try something like------>

include_once(XOOPS_ROOT_PATH . file.php');

3
glypo
Re: PHP Includes in blocks
  • 2006/10/3 18:17

  • glypo

  • Just popping in

  • Posts: 3

  • Since: 2006/10/1


Thank you for the reply.

I have got the includes to work. My problem is not including them but using them.

For example in one block I can include a script which has 4 variables. I can echo this variable in that block with no problem. However when I echo variable 2, 3 and 4 in other blocks (defined in the include in block 1) it doesn't work.

I have tried including the file in each block, this does work. However it does not give me my desired response as I have random generation in the script.

Basically I want to include a file once and echo variable in multiple blocks, I can get the include and echo to work in first blocks, but can't echo in others.

Any help would be greatly appreciated.

Thanks

4
wizanda
Re: PHP Includes in blocks
  • 2006/10/3 19:00

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Wow, you made it sound really complicated , have you thought of using a single header file with include there and then for the rest point to the header...?

5
glypo
Re: PHP Includes in blocks
  • 2006/10/3 22:12

  • glypo

  • Just popping in

  • Posts: 3

  • Since: 2006/10/1


Oh that sounds like a really good idea.

I have to admit I am very new to Xoops, and not 100% on what I'm doing.

Not exactly sure how I go about adding a header though, I've looked through the include folder and nothing is there that jumps out at me to modify to add my include.

Thanks for the help, I'm really appreciating this!

Login

Who's Online

193 user(s) are online (121 user(s) are browsing Support Forums)


Members: 0


Guests: 193


more...

Donat-O-Meter

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

Latest GitHub Commits