1
Anonymous
Using Include
  • 2004/3/9 3:42

  • Anonymous

  • Posts: 0

  • Since:


I will have multiple XOOPS site (A, B and C). Each of these sites will include some pages that are going to be the same for each of the sites. So sites A, B and C will all include file.php. The reason for this is that if file.php changes, it will automatically be picked up by all of the sites.

Here’s the problem I am having. I want the pages to be included in Xoops. I’ve searched through these forums and found several solutions. I’ve modified the main menu template file to directly access the file and put the appropriate header and footers includes to wrap my html. I’ve also used TinyContent and created an item on the main menu also. Both work, kind of.

If I have the following file, the text between the

shows as expected within Xoops.

include("../mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
?>

WEBSITE TERMS OF USE AGREEMENT
AND
DISCLAIMER OF LIABILITY



include(XOOPS_ROOT_PATH."/footer.php");
?>

However, if I add an include statement under the

tag as shown below to include the common text, the entire files shows up by itself (outside of Xoops). The include works because I see the text from the .inc file that sits on antoher server, but I lose the Xoops.

include("../mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
?>

WEBSITE TERMS OF USE AGREEMENT
AND
DISCLAIMER OF LIABILITY





include(XOOPS_ROOT_PATH."/footer.php");
?>

Hopefully, someone can point out the obvious to me. Thanks for any responses.

- The New Guy

2
Stewdio
Re: Using Include
  • 2004/3/9 4:22

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


Try this...

include("../mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
$xoopsOption['show_rblock'] = 1;
?>

Your content here

include(XOOPS_ROOT_PATH."/footer.php");
?>

3
Anonymous
Re: Using Include
  • 2004/3/9 4:29

  • Anonymous

  • Posts: 0

  • Since:


How is that any different then what I posted above (Besides the $xoopsOption['show_rblock'] = 1; line of code).

The code below works, except that including the 'terms.inc' makes the entire page show up outside of xoops. If I remove that include, the other text appears within xoops.

include("../mainfile.php");
include(
XOOPS_ROOT_PATH."/header.php");
?>

 WEBSITE TERMS OF USE AGREEMENT
AND
DISCLAIMER OF LIABILITY



include(INCLUDES_DIR.’terms.inc’); ?>

include(XOOPS_ROOT_PATH."/footer.php");
?>

4
Stewdio
Re: Using Include
  • 2004/3/9 4:34

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


I was only showing you what works for me.

I guess I misunderstood what your trying to do.

Good luck then..

*edit*

did some scrounging around and I think you need to rename your file with a .php extention. Something like: include XOOPS_ROOT_PATH."/include/your_file.php"; should work...

*edit again*

Also, if your file has the same code as I posted earlier, it should work fine.

5
Anonymous
Re: Using Include
  • 2004/3/10 17:00

  • Anonymous

  • Posts: 0

  • Since:


The local server (server A) has a file called TERMS.PHP which includes some html and then the include statement to include the TERMS.INC which lives on another server (server B).

If I understand the way the include works, as the file on server A is being parsed, it will go out and pull in the contact of the file on server B and then continue parsing the file on server A.

If I change the extension of TERMS.INC to TERMS.PHP on server B, then the INC file will be parsed on server B before coming over to server A. Although there is no PHP in the INC file, it doesn't really matter.

Nonetheless, I tried it anyway just for kicks, but it still didn't work.

Thanks though.

6
Stewdio
Re: Using Include
  • 2004/3/10 20:11

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


Dang, tough nut to crack. There has to be a way to do it. Your situation is less common then your standard include. Sorry I couldn't help more!

7
wcrwcr
Re: Using Include
  • 2004/3/10 20:26

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Hello

I?m not a coder but look at your code:
==================================
include(INCLUDES_DIR.’terms.inc’);
?>
=================================================
The INCLUDES_DIR is a variable?
Did you declare it anywhere?
Is the syntax of the line correct?

If you compare it with the example
========================================
include(XOOPS_ROOT_PATH."/header.php");
=========================================
don?t you find anything different?
Maybe:??????????
=================================
include(INCLUDES_DIR."/terms.inc");
?>
=======================================
When you get the page outside the XOOPS environment, the "terms.inc", shows correct?

As I told you, i?m not a coder and just asking this questions like I?ll do to myself
Hope it helps somehow.

8
Anonymous
Re: Using Include
  • 2004/3/10 20:41

  • Anonymous

  • Posts: 0

  • Since:


Yes, the INCLUDES_DIR variables is declared in the header.php if I remember correctly. I know the variable is working because like I said in my first post, when I have the include(INCLUDES_DIR.’terms.inc’); in the file, it is getting included as I would expect it to be.

The problem is that I am no longer within Xoops. Just a plain white page with all the text.

If I get rid of the include, the html text shows as expected within Xoops.

I'm not completey ignorant when it comes to programming. This just seems to be an unexpected behavior that i can't quite pinpoint.

9
wcrwcr
Re: Using Include
  • 2004/3/10 21:17

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


hi newGuy

what?s the difference between the " and ' signal?
I?m a completelly ignorant

If we could put something like the target "_blank" html?s function.......

thanks

10
Anonymous
Re: Using Include
  • 2004/3/10 21:31

  • Anonymous

  • Posts: 0

  • Since:


Alright, let me provide a little more detail here. Keep in mind that my XOOPS site and the "common" location are two seperate shard hosting services, but reside on the same box, thus the path below DOES work.

In the mainfile.php, I added the following line of code:
define(INCLUDES_DIR'/home/somedomain/public_html/common/');


I then updated the system_block_mainmenu.html and added the following line of code, thus providing a new link on the menu:
<class="menuMain" href="<{$xoops_url}>/terms.php">Termsa>



The contents of the "terms.php" file (which is in the root, same as mainfile.php and index.php) is:
include("mainfile.php");
include(
XOOPS_ROOT_PATH."/header.php");
$xoopsOption['show_rblock'] = 1;
?>

 WEBSITE TERMS OF USE AGREEMENT

    AND

    DISCLAIMER OF LIABILITY



include(INCLUDES_DIR.'terms.inc'); ?>  

include(XOOPS_ROOT_PATH."/footer.php");
?>


I don't need a '/' in front of the file name because it was defined as part of the path in DEFINE.

It also doesn't matter if I use a single quote ' or double quote " around the file name. The result is the same.

The object here is that when the user clicks on the menu item, it opens the local "terms.php" file and then includes soem common text located in "terms.inc"

Login

Who's Online

986 user(s) are online (309 user(s) are browsing Support Forums)


Members: 0


Guests: 986


more...

Donat-O-Meter

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

Latest GitHub Commits