Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2007, 11:42 AM
Rich's Avatar
Rich Rich is offline
 
Join Date: Mar 2004
Location: U.S.A
Posts: 921
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Defining the root directory

Hello,

I am currently working on an addon for one of my sites that doesn't encompass the global.php file from vBulletin. With that said, I am having an issue that I am hoping you all can help me with. (I have been playing and researching now for over an hour.)

This is the basic structure I have:

Root
Sub Folder
Sub Folder 2

Everything is pretty cut and dry when I am using any of my files in the root folder. The issue arises when I am in the Sub Folders.

I have a new page in a sub folder that calls on the header file in the root folder. That is easy enough to get called by simply typing ../header.php. The problem though is that header.php calls on 3 files also in the root folder.

Instead of including the file from the root folder, it is trying to locate the file in the sub folder, which obviously doesn't exist.

How can I go about correcting this without having to duplicate the files being called? I know there is a way to define the roots directory globally, but I haven't been able to figure out how.
Reply With Quote
  #2  
Old 02-18-2007, 12:21 PM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using the full server path on the includes or chdir to root and then chdir back if needed.
Reply With Quote
  #3  
Old 02-18-2007, 12:35 PM
Rich's Avatar
Rich Rich is offline
 
Join Date: Mar 2004
Location: U.S.A
Posts: 921
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello,

Are you suggesting I edit the files directly and add the absolute path? I am trying to avoid that. I attempted chdir but it wasn't working in the scope of how I was using it.

This is my exact issue:

Directory Sub Folder > Article.php
Root > Header.php, Footer.php, Vars.php, Left.php

Article.php calls header and footer like this:
PHP Code:
include("../header.php"); ?> 
That works fine.

header.php begins by calling on the vars.php file as the very first command, which is in the same directory as the header.php file. It is looking for that file however in the sub folder.

Seeing as the header and footer files are called in every file, I was hoping that perhaps there would be a way to define globally to read from the root folder for every included file without having to edit every included file. (There are many more files that are used pending the pages usage.)

What will end up happening, if i understand you correctly, is that i will need to edit almost 45 different files. If I could include a simple "scope" method for forcing the page to read from the root directory, unless otherwise defined, it would be great.

I know this can be done, but i can't seem to locate HOW it is done. lol
Reply With Quote
  #4  
Old 02-18-2007, 12:53 PM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Snip from http://www.php.net/manual/en/function.include.php page:
Quote:
Files for including are first looked in include_path relative to the current working directory and then in include_path relative to the directory of current script. E.g. if your include_path is ., current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in include_path relative to the current working directory.
So you could set the include_path in php.ini or use ini_set to set it:
Code:
ini_set('include_path', '.:../:./subfolder:../subfolder'); // or whatever
Reply With Quote
  #5  
Old 02-18-2007, 12:57 PM
jasbell jasbell is offline
 
Join Date: Feb 2007
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am interested in this also.

I have two directory levels for now:
www.mysite.com
forum.mysite.com

Since everything is installed in the /forum directory which the url forum.mysite.com points to, all calls from www.mysite.com point to stuff in the second level (/forum level).

What is the best way to manage this and minimize maintenance?
Reply With Quote
  #6  
Old 02-18-2007, 11:32 PM
Kungfu Kungfu is offline
 
Join Date: Dec 2005
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you could create a variable with the absolute path.

Also when including files you can use DIR if global is called or CWD. DIR should be your forum path.

You could put something in your initialize script like
$rootDIR = "website.com/public_html/root";

Then when you need it you can call it like
global $rootDIR and use that path. This way you would only edit one location to set the root.
Reply With Quote
  #7  
Old 02-19-2007, 08:30 AM
Rich's Avatar
Rich Rich is offline
 
Join Date: Mar 2004
Location: U.S.A
Posts: 921
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello,

Thanks Calorie. I played with that a bit but couldn't get it to work effectively. Kungfu, that I already knew. The only problem with that is I already have massive amounts of pages created. I would need to edit each one in order to have that effective across the entire site. Instead, I created 2 new header and footer files for subdirectories to call. While developmentally it is a little odd, it serves its purpose. Those files use absolute paths, so everything is loading accordingly as they call every file directly. (Using a variable like that listed above.)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:22 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04063 seconds
  • Memory Usage 2,224KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete