Jump to content

Recommended Posts

Ok, im gonna try and simplifiy my explination as much as possible to make sure you guys understand what I want to do. Heres the deal. Im making a site where every aspect of it can be edited from an external file. Before I explain my problem. Im gonna try explain what I want to do.

Heres a text example of how my server is setup right now in terms of folders and php files.
*note, following is not my code, I just used the code quotes to keep the formating.

[code]  
ROOT--------> index.php
              [Folder: System] ------> [Folder: Engine]----------------------->engine.php
                                       [Folder: Modules]------>[Folder: Menu]---->menu.php[/code]

So the Url's for the files are:

Short urls examples
index.php
System/Engine/engine.php
System/Modules/Menu/menu.php

Full urls examples
[a href=\"http://www.websiteURL.com/index.php\" target=\"_blank\"]http://www.websiteURL.com/index.php[/a]
[a href=\"http://www.websiteURL.com/System/Engine/engine.php\" target=\"_blank\"]http://www.websiteURL.com/System/Engine/engine.php[/a]
[a href=\"http://www.websiteURL.com/System/Modules/Menu/menu.php\" target=\"_blank\"]http://www.websiteURL.com/System/Modules/Menu/menu.php[/a]

In my engine.php. I have the following example of code.

[code]<?
$MenuURL = '/System/Modules/Menu/Menu.php'; //Menu Module URL
?>[/code]

In my Index.php. I have the following example of code in the header

[code]<? include ('/System/Engine/Engine.php');?>[/code]

and then i have this code where i want my menu to appear

[code]<?php include ($MenuURL);?>[/code]

This setup works fine. The engine is loaded into the index and then menu.php loads the variable url and the menu shows up. The problem with this however is if i wanted to put the menu in another page I wouldnt be able to because the url in the engine is based from the root of the of the server. Is there a way to make the include() command to be rerouted back to the root of the server and then locate the file from there?

I tried using this:

[code]<?php include ($_SERVER['DOCUMENT_ROOT'].($MenuURL));?>[/code]

And it worked on my apache test server but the urls in the source code started from the c:\ all the way to my apache www directory and then adds on the url from the engine to the end of it completing the Url. When I tested this on an online server. It didnt work. What is wrong with the code? Is this even possble to do and if not what do you think is the best way I should go about this in order to get my files working together like so:

[img src=\"http://revonet.org/stuff/leonix/engine.gif\" border=\"0\" alt=\"IPB Image\" /]

Please help, and Thanks.
Link to comment
https://forums.phpfreaks.com/topic/11290-using-inlcude/
Share on other sites

Wow, I rarely see a question posted like this... Nice [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

[code]<?php

$file = $_SERVER['DOCUMENT_ROOT'] . '/System/Engine/Engine.php';
include $file;

?>[/code]

Should work. Don't use round brackets to group strings, it won't work.
Link to comment
https://forums.phpfreaks.com/topic/11290-using-inlcude/#findComment-42268
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Wow, I rarely see a question posted like this... Nice [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] [/quote]
I write alot of tutorials [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] not used to asking questions.

Your solution fixed my problem, Thanks.
Link to comment
https://forums.phpfreaks.com/topic/11290-using-inlcude/#findComment-42582
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.