How do I use php includes in the blocks?

Support for the IM Portal Project

Moderator: Integra Moderator

How do I use php includes in the blocks?

PostAuthor: oldreb » Wed May 09, 2007 9:50 pm

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
Last edited by oldreb on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

oldreb
Newbie
Newbie
 
Posts: 1
Likes: 0 post
Liked in: 0 post
Joined: Wed May 09, 2007 9:36 pm
Cash on hand: 0.00

PostAuthor: Whisky » Wed May 09, 2007 10:59 pm

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
Last edited by Whisky on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
I am the Lizard King, I can do anything

Whisky
Sr Integra Member
Sr Integra Member
 
Posts: 256
Likes: 0 post
Liked in: 0 post
Joined: Thu May 18, 2006 1:28 am
Cash on hand: 0.00
Location: Brussels

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

PostAuthor: IntegraMOD » Wed May 30, 2007 12:22 pm

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.
Last edited by IntegraMOD on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
Image
Please do not PM for support
User avatar
IntegraMOD
Administrator
Administrator
 
Posts: 459
Likes: 0 post
Liked in: 0 post
Joined: Sat Mar 11, 2006 3:46 pm
Cash on hand: 0.00
Bank: 100.00
Location: Seattle Wa

PostAuthor: bariq » Thu May 31, 2007 6:50 pm

.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
Last edited by bariq on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

bariq
Members
Members
 
Posts: 65
Likes: 0 post
Liked in: 0 post
Joined: Sun Apr 09, 2006 6:52 pm
Cash on hand: 0.00

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

PostAuthor: IntegraMOD » Thu May 31, 2007 10:07 pm

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?
Last edited by IntegraMOD on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
Image
Please do not PM for support
User avatar
IntegraMOD
Administrator
Administrator
 
Posts: 459
Likes: 0 post
Liked in: 0 post
Joined: Sat Mar 11, 2006 3:46 pm
Cash on hand: 0.00
Bank: 100.00
Location: Seattle Wa

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

PostAuthor: Coder » Mon Jul 09, 2007 12:45 pm

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!
Last edited by Coder on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

Coder
Newbie
Newbie
 
Posts: 16
Likes: 0 post
Liked in: 0 post
Joined: Tue Jun 26, 2007 7:43 am
Cash on hand: 0.00
Location: Phoenix, AZ

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

PostAuthor: IntegraMOD » Thu Jul 12, 2007 8:30 pm

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?
Last edited by IntegraMOD on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
Image
Please do not PM for support
User avatar
IntegraMOD
Administrator
Administrator
 
Posts: 459
Likes: 0 post
Liked in: 0 post
Joined: Sat Mar 11, 2006 3:46 pm
Cash on hand: 0.00
Bank: 100.00
Location: Seattle Wa

PostAuthor: Whisky » Fri Jul 20, 2007 12:20 am

code syntax error, please post the whole contain of
blocks_imp_rosterstats.php
if you want us to spot your error.
Last edited by Whisky on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
I am the Lizard King, I can do anything

Whisky
Sr Integra Member
Sr Integra Member
 
Posts: 256
Likes: 0 post
Liked in: 0 post
Joined: Thu May 18, 2006 1:28 am
Cash on hand: 0.00
Location: Brussels


Return to IM Portal Support Forum

Who is online

Registered users: Bing [Bot], Helter, Majestic-12 [Bot]