Page 1 of 1

How do I use php includes in the blocks?

PostPosted: Wed May 09, 2007 10:50 pm
Author: oldreb
Your phpBB Version: 2.0.
phpBB Type: phpBB / IMPortal
MODs: Yes
Your knowledge: Advanced Knowledge
Board URL: http://nucsa.org/forums/

PHP Version:
MySQL Version:


What was done before the problem appeared?



What was done to try to solve the problem?




De.scription and Message

I would like to call a php item in a new IM block.

It's am image rotator and you can see how it works on my home page http://nucsa.org then scroll down about half way and look on the left there is an image of a T-shirt or something like that.
The image changes each time the page is reloaded.

The call tag looks like this
<php>


Is there a way to get this to work in a new IM block?
When I add the code in the block from ACP nothing happens.


Thanks ahead

PostPosted: Wed May 09, 2007 11:59 pm
Author: Whisky
You can't add your PHP code from the ACP you have to create a PHP file for it and a template file

A block = 1 php file + 1tpl file

here's how I do when I've got a 100%php block:

blocks/my_new_block.php

Code: Select all
<php>assign_vars(array('THINGS_TO_SEND_TO_TPL' => sprintf($text)));         }}  My_new_function();  ?>


And the template:

templatesmythemeblocksMy_new_block.tpl
Code: Select all
<table>     <tr>         <td><span>{THINGS_TO_SEND_TO_TPL}</span></td>     </tr></table>


Thens you will be able to choose your block in the ACP, it's loading all PHP files contained in /block

Re: How do I use php includes in the blocks?

PostPosted: Wed May 30, 2007 1:22 pm
Author: IntegraMOD
I came here with a similar question and found this post.

In looking through the example .tpl and .php in the reply by Whisky, I am trying to figure out where I would actually place the file I want to include.

For example, the file is, stats.php (I'll most likely have to include the full URL).

Where would I place this in the examples?

Thank you.

PostPosted: Thu May 31, 2007 7:50 pm
Author: bariq
.php file goes into <root>/blocks
.tpl file goes into <root>/templates/<theme>/blocks


hope this helps.. you can search for the birthday mod thread submitted by me sometime back, it contains the php and tpl files to be used as reference

Re: How do I use php includes in the blocks?

PostPosted: Thu May 31, 2007 11:07 pm
Author: IntegraMOD
I may not of been clear on what I was asking. In the code examples above, where would I actually reference my file, "websiteurl/roster/stats.php" (for example) that I want to be included?

Re: How do I use php includes in the blocks?

PostPosted: Mon Jul 09, 2007 1:45 pm
Author: Coder
Here's Whisky's blocks/my_new_block.php example again, but with the include included:
Code: Select all
<php>assign_vars(array('THINGS_TO_SEND_TO_TPL' => sprintf($text)));         }}  My_new_function();  ?>

Hope that helps!

Re: How do I use php includes in the blocks?

PostPosted: Thu Jul 12, 2007 9:30 pm
Author: IntegraMOD
Thanks for the reply Coder...

Still trying to piece this all together... slowly (newb here)

When I enable the block, I get the following error...

[code]Parse error]

So, something about the } the site doesn't like?

PostPosted: Fri Jul 20, 2007 1:20 am
Author: Whisky
code syntax error, please post the whole contain of
blocks_imp_rosterstats.php
if you want us to spot your error.