Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:26:16+00:00 2026-06-07T23:26:16+00:00

I know how to do this in ColdFusion, I am trying to get the

  • 0

I know how to do this in ColdFusion, I am trying to get the same syntax to define root directories, sub directories and filenames as needed (the goal is that when the client clicks on any page it’s title will be defined by the section or directory it lies in).

This is the code I have for CF (sorry there is alot of it):

<cfset REQUEST.directory_path = listDeleteAt(CGI.script_name, listLen(CGI.script_name, "/"), "/")>
<cfset REQUEST.directory_top = listFirst(CGI.script_name, "/")>
<cfset REQUEST.filename = listFirst(listLast(CGI.script_name, "/"), ".")>

<!--- Array of directory names --->
<cfset REQUEST.directory_array = ListToArray(REQUEST.directory_path,"/")>
<cfif ArrayLen(REQUEST.directory_array) GTE 1>
<cfset REQUEST.directory_parent = REQUEST.directory_array[ArrayLen(REQUEST.directory_array)]>
<cfelse>
    <cfset REQUEST.directory_parent = REQUEST.filename>
</cfif>

<cfset VARIABLES.filename = REQUEST.filename>
<cfset VARIABLES.directory = REQUEST.directory_parent>
<cfset VARIABLES.primarydir = REQUEST.directory_top>
<cfset VARIABLES.secondarydir = GetToken(REQUEST.directory_path,  2 ,  "/")>
<cfset VARIABLES.tertiarydir = GetToken(REQUEST.directory_path,  3 ,  "/")>
<cfset VARIABLES.quaternarydir = GetToken(REQUEST.directory_path,  4 ,  "/")>
<cfif VARIABLES.primarydir EQ "index.cfm">
    <cfset VARIABLES.primarydir = "index">
</cfif>

Then I have a simple switch statement to define my various sections:

<cfswitch expression="#VARIABLES.PrimaryDir#">
<cfcase value="photography">
    <cfset VARIABLES.page_title_section = "Home">
    <cfset VARIABLES.PrimaryDir EQ 'photography'>
</cfcase>
<cfcase value="clients">
    <cfset VARIABLES.page_title_section = " Clients">
    <cfset VARIABLES.PrimaryDir EQ 'clients'>
    </cfcase>

etc, etc.

I think I am OK creating the switch statement in PHP, but how do I define the directory structure as above? I did look here: http://php.net/manual/en/function.pathinfo.php but I am not 100% sure what I am passing to php for this to work.

Hope someone can help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:26:19+00:00Added an answer on June 7, 2026 at 11:26 pm

    I’m know next to nothing about ColdFusion, but if I understand you correctly you can get the same effect by inspecting the $_SERVER['REQUEST_URI'] property:

    // Use substring to ignore first forward slash
    $requestArray = explode('/', substr($_SERVER['REQUEST_URI'],1));
    

    This will give you a single dimensional array equal to the current request. For instance if a user requests the following URL:

    http://www.domain.com/dir1/dir2/dir3/page.php
    

    Then $requestArray will be:

    Array( 0 => 'dir1', 1 => 'dir2', 2 => 'dir3', 3 => 'page.php')
    

    If the user requests the home page (http://www.domain.com) then the request array will be empty.

    For more information, check out the manual entry for $_SERVER

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Know this might be rather basic, but I been trying to figure out how
I know this is an easy concept, but I just can't seem to get
I am using ColdFusion 8. I am trying to write this code block in
I'm trying to get an MD5 hash of a value in ColdFusion. I tried
I'm trying to figure out how to implement this relationship in coldfusion. Also if
I get this somewhat frequent error and I don't know what's causing the trouble.
Does anyone else get this problem or know a solution / workaround I could
I'm trying to calculate password entropy in ColdFusion (I know I could do it
i know this is a stupid question but i d'ont know how to do
I know this is a frequently asked question and I havent got a clear

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.