Custom Block running php code = weird results

Current Version: 1.0.6
Released: 09.01.10
Forum rules
Before creating a new support thread, please take a look in the board3 Portal FAQ and use the search!
Many questions have already been answered.
Locked

Topic author
crazydiamond
Active Member
Posts: 5
Joined: 30. January 2011 18:31

Custom Block running php code = weird results

Post by crazydiamond »

Your Portal Version: 1.0.6RC3
Your phpBB Type: Standard phpBB3
MODs installed: Yes
Your knowledge: Basic Knowledge
Boardlink: http://92.232.81.30/phpbb/

What have you done before the problem was there?
I have added a custom left block and I have turned on "Allow php in templates" In the ACP

What have you already tryed to solve the problem?
EVERYTHING including pulling on my hair!

Description and Message
Please please someone help me, I am going out of my mind with this Custom block.

I have made a tide script that will pull off todays tide from a list of the tides for the month.
It works great and displays todays tide.

I want this in a custom left block, So I enabled php in templates and have tried every php command in the world to display my php script results.

Code: Select all

<!-- INCLUDE portal/block/todaytide.php -->

Code: Select all

<!-- PHP --> include("/styles/supernova/template/portal/block/todaytide.php");  <!-- ENDPHP -->

Code: Select all

<!-- PHP -->require_once("/tides_processor.php"); tides(0);<!-- ENDPHP -->
These actually work but give me odd results.
In my custom block it says that
Tide data is being updated. Please refresh the page.
This is an error message that means the sript is not working properly.
It works fine if I point my browser to the todaytide.php file on the server, so why not within the custom block?

I did read here knowledge/kb_show.php?id=51
Adding PHP Code for your block
If you need to execute PHP code for your new block, there is an easy way to do this. Adding PHP Code to the block file will not do anything at all. Open portal/block/additional_blocks.php and add your PHP right in front of this:
CODE: SELECT ALL
?>


Make sure you leave no spaces before <?php and after ?> and save the file as UTF8 without BOM
I tried adding my php Include in front of that and the script works but it loads above the banner on my portal home page :?: looks stupid

I really do not understand this additional_blocks.php part

Please someone help me, I have spent hours on this and this is the only place I can get answers.[/i]
User avatar

Marc
Dev
Posts: 2504
Joined: 17. July 2008 21:08
phpBB.de User: marc1706
phpBB.com User: Marc
Location: Clausthal-Zellerfeld / München
Contact:

Re: Custom Block running php code = weird results

Post by Marc »

Your script probably does not use the phpBB template engine. For an introduction to the phpBB template syntax, take a look at the phpBB.com wiki: wiki.phpbb.com

Topic author
crazydiamond
Active Member
Posts: 5
Joined: 30. January 2011 18:31

Re: Custom Block running php code = weird results

Post by crazydiamond »

Thanks Marc.

How comes the php script works when I put the code in additional_blocks.php?
It runs but puts the results above the Portal Banner? So obviously the phpbb can handle my script but the blocks cannot.

I was really hoping to be able to run a standard .php file from within a Block, but if this is not possible then I am best off just designing a home page in php that will run what I want.

Another question I have is.. Is it possible to copy the portal menu onto other php links.
If I wanted to make a link in the menu "Weather" and when a user clicks on that link then they go to weather.php but as its a custom page I will not have the menu. Would be good to keep the menu and banner etc.

Cheers for your time
User avatar

Marc
Dev
Posts: 2504
Joined: 17. July 2008 21:08
phpBB.de User: marc1706
phpBB.com User: Marc
Location: Clausthal-Zellerfeld / München
Contact:

Re: Custom Block running php code = weird results

Post by Marc »

That is because the PHP script outputs the page before the phpBB template engine does.

For adding a new menu item, take a look at this: knowledge/kb_show.php?id=16

For showing a page with the portal blocks on the side, you could use the portalview MOD as a base.
Locked

Return to “board3 Portal 1.0.x - English Support”