Re: [SMARTY] Conditionally include file based on document location
| From: | Eric C. Pollitt | Date: | Thu, 19 Sep 2002 01:22:35 +0000 |
| Subject: | Re: [SMARTY] Conditionally include file based on document location | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5995@lists.php.net to get a copy of this message | ||
Thanks for the insight, but I'm not clear on how to implement this. Here is
what I have so far:
<?php
switch ($DOCUMENT_URI) {
case '/home/globalhemp/www/':
include("/home/globalhemp/www/includes/apple.inc");
break;
case '/home/globalhemp/www/Archives/':
include("/home/globalhemp/www/includes/quicktime.inc");
break;
case '/home/globalhemp/www/Archives/Essays/':
include("/home/globalhemp/www/includes/quicktime_download.inc");
break;
}
?>
Perhaps $DOCUMENT_URI is not correct...perhaps it should be $PATH_INFO? Or
should I have some sort of return or print statement?
TEST URL: http://globalhemp.phpwebhosting.com/switch.php
Thanks,
Eric C. Pollitt, Founder
401 E. Illinois Ave.
Peoria, IL 61603
Global Hemp - Portal to the hemp community
http://www.globalhemp.com/
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety."
-- Benjamin Franklin, Historical Review of Pennsylvania, 1759
---------------------------------------------------------------------------
The information contained in this e-mail message may be privileged,
confidential, and protected from disclosure. If you are not the intended
recipient, any further disclosure or use, dissemination, distribution, or
copying of this message or any attachment is strictly prohibited. If you
think that you have received this e-mail message in error, please delete it
and notify the sender.
> From: "Eric C. Pollitt" <eric@globalhemp.com>
> Date: Tue, 17 Sep 2002 15:36:28 -0500
> To: <smarty-general@lists.php.net>
> Subject: [SMARTY] Conditionally include file based on document location
>
> I would like to know how to conditionally included a file based on the
> document location.
>
> The purpose is for placement of location-specific navigation menus.
>
> I'm not interested in DHTML hierarchical drop-down menus, rather inserting
> ready made HTML files using perhaps (?) DOCUMENT_URI (?) and error checking
> logic.
>
> ----------------------------------------------------------------------------
> EXAMPLE
>
> If DOCUMENT_URI is "/" (home) then the following file included:
>
> URL: <http://www.globalhemp.com/includes/apple.html>
>
> If DOCUMENT_URI is "/quicktime/" then the following file included:
>
> URL: <http://www.globalhemp.com/includes/quicktime.html>
>
> If DOCUMENT_URI is "/quicktime/download/" then the following file included:
>
> URL:
> <http://www.globalhemp.com/includes/quicktime_download.html>
> ----------------------------------------------------------------------------
>
> The error checking logic would be for child directories that don't have
> their own include file and thus would use a parent directory include file.
> If a parent directory file doesn't exist, it would include the top-level
> (home) include file.
>
> The closest PHP example that I have found thus far follows:
>
> ----------------------------------------------------------------------------
> [INCOMPLETE] PHP CONDITIONAL INCLUDE EXAMPLE
> Extracted from: <http://www.jwweb.com/20010629.html>
>
> <?php
> if ($location == "quicktime") {
> include("quicktime.inc");
> if ($location == "quicktime/download") {
> include("download.inc");
> } else {
> include("home.inc");
> }
> ?>
> ----------------------------------------------------------------------------
>
> THANKS!
>
> Eric C. Pollitt, Founder
> 401 E. Illinois Ave.
> Peoria, IL 61603
> Global Hemp - Portal to the hemp community
> http://www.globalhemp.com/
>
> Create like a god. Command like a king. Work like a slave!
> -- Constantin Brancusi
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>