Avendium Posted June 6, 2006 Share Posted June 6, 2006 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 examplesindex.phpSystem/Engine/engine.phpSystem/Modules/Menu/menu.phpFull 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. Quote Link to comment https://forums.phpfreaks.com/topic/11290-using-inlcude/ Share on other sites More sharing options...
poirot Posted June 6, 2006 Share Posted June 6, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11290-using-inlcude/#findComment-42268 Share on other sites More sharing options...
Avendium Posted June 6, 2006 Author Share Posted June 6, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/11290-using-inlcude/#findComment-42582 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.