php-general | 2000071
Date: 07/03/00
- Next message: Mark Newnham: "[PHP] Newbie: recursing directories"
- Previous message: Reuben D Budiardja: "Re: [PHP] Second question of the day. PHP's version of Perl's $#varName?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi all
(sorry for the long email. Found it difficult cutting this down)
I am running into a little bit of a problem with the way I am coding and
would like some suggestions. I am trying to modularise the development of a
couple of websites. Basically, we have created a series of stand-alone
modules (with very little design) which are designed to "plug in" within a
web page. For example, if the interface had a top band, a left-hand band
for navigation and a bottom band, then the module would sit in the central
area. I wanted to "include" this module within this central area, but have
run into a problem with the include statement
Each module that we have created sits in it's own folder. If I go into the
module folder (let's call it "Articles") and run the index.php file, I want
to "include" the "top" and "bottom" parts of the main interface (which is in
the root folder of the application, one level up) then the images do not
show, and the links do not work. Within this index page is a SWITCH (or
if-then-else) statement which determines which parts of the module it will
display or run as well as building the generic interface and including any
other necessary files (such as functions etc). This works based on an
"action" command. Here is some sample code:
<?
// include files that might be necessary
include "application.php";
include "functions.php";
include "session_information.php";
// display the top of the main interface
include "../main_interface_top.php";?>
<?
// insert the appropriate part of the module, based on
// a switch statement
switch ($action){
case "displayfront":
include "articles_index.php";
break;
case "search":
include "search.php";
break;
case "showdetail":
include "articles_detail.php";
break;
default:
include "articles_index.php";
}
?>
<? include "../main_interface_bottom.php";?>
This all works fine under normal circumstance (I have used this method a
lot) but now that I want to have seperate modules in sub-folders the method
seems a bit flawed :)
I have come up with a possible solution, but need some more expert advice to
help me out. I decided to include an "application.php" file that each
module will have (for settings, preferences etc) and I included an
"$application_root" variable within this which would tell the script where
the root level of the site was. For example:
<?$app_root = "../"; ?>
would tell the application to look to the root level (and therefore to the
level where the main design interface is located) it would have to step down
one level. In order for this to work though, I had to change some of the
coding within the main interface pages and included the app_root variable,
for example:
<img src="<? echo "$app_root";?>images/header_left.gif">
If we were accessing the main interface pages from their own directory then
this $app_root variable would not be set and therefore the images would
still be shown. If we were within one of the module directories (for
example "articles") then the images would still be displayed and the links
would still work.
Am I being incredibly naive here? Is there a much better way of doing this
whilst leaving my files seperated into sub-folders?
I started this line of coding based on the fusebox method (www.fusebox.org)
when I used Cold Fusion and it has stuck with me in PHP (although refined
and made better by PHP of course :) )
Any help, coding suggestions appreciated
With thanks and best wishes to you all
Ade
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Mark Newnham: "[PHP] Newbie: recursing directories"
- Previous message: Reuben D Budiardja: "Re: [PHP] Second question of the day. PHP's version of Perl's $#varName?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

