Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 11:58 pm EST
Geeklog Forums
PHP Includes
include
Anonymous
I need help trying to call a php include in a php block. This is the code that I have in HTML that works fine.
<!--#set var="cat" value="349" -->
<!--#set var="show" value="products" -->
<!--#set var="list_products" value="Y" -->
<!--#include virtual="avail_products_home.php" -->
Now, I tried putting that code into the following function in lib-commmon.php and tried calling it into a php block but all I got was a blank white page.
function phpblock_truthstore_items( $cat = 348, $show = both, $list_products = yes )
{
chdir("../../truthstore/cart/customer/"
include "avail_products_home.php";
}
Anyone have any ideas on how to get this code to work.
<!--#set var="cat" value="349" -->
<!--#set var="show" value="products" -->
<!--#set var="list_products" value="Y" -->
<!--#include virtual="avail_products_home.php" -->
Now, I tried putting that code into the following function in lib-commmon.php and tried calling it into a php block but all I got was a blank white page.
function phpblock_truthstore_items( $cat = 348, $show = both, $list_products = yes )
{
chdir("../../truthstore/cart/customer/"
include "avail_products_home.php";
}
Anyone have any ideas on how to get this code to work.
12
14
Quote
Status: offline
vinny
Site Admin
Admin
Registered: 06/24/02
Posts: 352
Location:Colorado, USA
To start with, I'd suggest replacing:
function phpblock_truthstore_items( $cat = 348, $show = both, $list_products = yes )
{
chdir("../../truthstore/cart/customer/");
include "avail_products_home.php";
}
--with this--
function phpblock_truthstore_items( $cat = 348, $show = both, $list_products = yes )
{
include "/absolute/path/truthstore/cart/customer/avail_products_home.php";
}
Also, make sure that "avail_products_home.php" doesn't pass any headers or have extra spaces before (both of which will cause problems).
Did you try looking at the source of the "blank page". If there was any output at all having that might help. Also, keep in mind that phpblocks are expected to return their output and not print it to the screen themselves (if you need to look into ob_start on php.net). Take a look at some of the example blocks in lib-custom.php for some simple examples.
-Vinny
Text Formatted Code
function phpblock_truthstore_items( $cat = 348, $show = both, $list_products = yes )
{
chdir("../../truthstore/cart/customer/");
include "avail_products_home.php";
}
--with this--
Text Formatted Code
function phpblock_truthstore_items( $cat = 348, $show = both, $list_products = yes )
{
include "/absolute/path/truthstore/cart/customer/avail_products_home.php";
}
Also, make sure that "avail_products_home.php" doesn't pass any headers or have extra spaces before (both of which will cause problems).
Did you try looking at the source of the "blank page". If there was any output at all having that might help. Also, keep in mind that phpblocks are expected to return their output and not print it to the screen themselves (if you need to look into ob_start on php.net). Take a look at some of the example blocks in lib-custom.php for some simple examples.
-Vinny
12
16
Quote
adydas
Anonymous
I think the probles is in fact that this include is meant to print out the results to an HTML page. I wouldn't know how to make it a return value. Would there be any way of just bypassing this and making it work like a regular html include.
20
15
Quote
Status: offline
vinny
Site Admin
Admin
Registered: 06/24/02
Posts: 352
Location:Colorado, USA
No, there is no way to make it work like a regular HTML include.
Once again I suggest you look at the ob_start function on php.net (RTFM). You'll find instructions on how to buffer output and then you can return the output generated by your include.
-Vinny
Once again I suggest you look at the ob_start function on php.net (RTFM). You'll find instructions on how to buffer output and then you can return the output generated by your include.
-Vinny
11
16
Quote
All times are EST. The time is now 11:58 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content