Question about Directories & Indexes

Is it a bad design to have a directory in the Web Root for each “Section” of your website, and then inside of each directory, have an “index.php” file??

For example, I am thinking of having the following “Sections” in my website…

[INDENT]- Finance
- Legal
- Management
- Marketing
- Interviews
- Outsourcing
- How-To's
- Resources
- Laws & Regulations
- Glossary
- Case-Studies
- Other
[/INDENT]

Originally, I just had a directory called “articles” with an “index.php” file that served as a generic template to serve up articles based on the selected Section.

So if your pretty URL was…

http://local.debbie/finance/

…then you would be taken to the ugly URL…

http://local.debbie/articles/index.php?section=finance

The problem with this is that all my Sections can offer is just a listing of Articles?!

But I am realizing that it would be nicer to have a “Landing Page” for each “Section” which would serve the same purpose as my main “Home Page”. That is, it would be a way to highlight certain things, provide links to different resources (e.g. Graphs, Interviews, Reference, Q&A, Multimedia), as well as the Articles that I currently offer.

Does that make sense??

Sincerely,

Debbie

hi,
if its problem of ugly url .
you can make pretty url with URL rewrite and htaccess.

Instead of physical directories with index.php in them, use htaccess rewriting (vs redirecting, which is what your example is). It’s essentially the same process, but the URL doesn’t change to the user.

Before I dive into the rabbit hole, maybe you (and others) can help me figure out if what I am trying to do makes sense?!

Currently my website has a Navigation Bar with various Sections in it: Finance, Legal, Management, etc.

When a user clicks on a “Tab”, my mod_rewrite grabs the “Section” in the URL, and redirects to something like this…

http://local.debbie/articles/index.php?section=legal

(screenshot)

So what you would have is a “Listing of Legal Articles” in this case.

Now, that works okay, but it has occurred to me (in the 11th hour) that my website is supposed to be about more than JUST articles, so what I want to do for most Sections, is to create a “Landing Page” which includes disparate Links, Graphs, etc in addition to a link to yet another page which is like my current “Listing of <section> Articles”

The Wall Street Journal sorta has what I am looking for…

(screenshot)

(You can see that the WSJ not only has articles related to a given Section, but they also have Graphs, Links, and even Ads specific to just that Section. I think that looks better than what I currently have, which is rather one-dimensional…)

So to test things out, I want to make it so if a person clicks on the “Finance” tab, they are taken here…

(Displayed URL) http://local.debbie/finance/

(Actual Path) http://local.debbie/finance/index.php

And for all other Sections, things would remain as they currently are, that is…

(Displayed URL) http://local.debbie/legal/

(Actual Path) http://local.debbie/articles/index.php?section=legal

Does that make sense??

If so, then how does all of this relate to your advice above?? :-/

Sincerely,

Debbie

You’re talking about two different animals. The original question (at least as I read it) was about creating a completely separate file/directory structure for each section. My point was that would be overkill and no real benefit to having several files which do exactly the same thing. That just adds overhead and work for maintenance. From my perspective, with the advent of URL rewriting, the only reason to have separate physical folders is for a) security and/or b) to group complementary structure elements (images in one place, css in another, binaries in another, etc).

This second question is a logical one - does it make sense to have a landing page for a section? Yes, it does. That’s what I would assume a section would be for - to show anything related to that section, whether it’s articles, links, infographics, whatever.

Okay, so you support my “revelation” that it would make more sense to drop people off at a “Legal Home Page” when they click on the “Legal” section tab. (And then from there they could click on another link which would take them to a “Listing of Legal Articles” like in my first screenshot above, right??)

What I was trying to say in my OP, and then again in my last post was, "So how do I go about getting the end result - that we agree on - of having a “Section Landing Page”?

Let’s say I have the following Navigation Tabs (i.e. Sections)…

  • Home
  • Finance
  • Legal
  • Management
  • Small Business
  • Other

And for whatever reason, let’s say that when you click on the “Legal” or “Management” sections I just want a “Listing of Articles” to appear like I currently have.

Why? Maybe because I don’t have the time to make a legitimate “Landing Page” for those Sections when I go live?!

However, if you click on “Home”, then I want you to be taken to the “index.php” file which has all of my Website Home Page code.

And if you click on “Finance”, then I want you to be taken to a different “index.php” file which would build my “Finance Landing Page” code.

And if you click on “Small Business”, then I want you to be taken to yet another (different) “index.php” file which would build my “Small-Business Landing Page” code.

And so on…

Off Topic:

I’m sure that if I was using fancy stuff like OOP and Model-View-Controller, and so on, that there is a more “sophisticated” way of doing all of this. But the reality is that v2.0 of my website is completely done, and I just want to add these “Section Landing Pages” - where applicable - before going live. So re-tooling all of my code is not an option!

Since - as I see it - I need a different PHP script for my “Website Home Page” vs. my “Finance Landing Page” vs. my “Small-Business Landing Page”, then I need some way to distinguish the “index.php” files, and I thought maybe how you do that is creating separate Directories in your Web Root. (Old-school, I’m sure?!)

(In my mind - at this late stage of the game - it would be TOO DIFFICULT - to create one “master” index.php file and try to load in the appropriate code depending on the type of “Landing Page” that was needed. Also, since once my Sections are set, they likely won’t grow or change much, if ever, it isn’t like I need tons of flexibility here, if you follow me?)

So, we seem to agree with my need for “Landing Pages” for each Section, and then from there I can take people to a “Listing of <Section> Articles” page.

However, I have a few problems that I need help with…

1.) I need a distinct “index.php” (or whatever) for each Section’s “Landing Page” because each will be very different.

2.) I need a way to have some Sections go to my new “Landing Page”, and other Sections go to the “Listing of Articles” page that I have now, which is done like this…

http://local.debbie/articles/index.php?section=legal

3.) Because I don’t want to overly complicate things, I think how I present “Listing of <Section> Articles” can use the same code/file/approach across Sections.

So #1 above needs to be able to take me from, say, “Finance Landing Page” at…

(Displayed URL) http://local.debbie/Finance/

to something like this…

http://local.debbie/articles/index.php?section=finance

That is another way of describing what I need help with…

Does that make more sense? (I hope so, because I am out of ways to describe the problem I am trying to fix.) :frowning:

Thanks in advance…

Sincerely,

Debbie

I guess I’m confused - I’m assuming you have the data for these sections in a database?

If so, all you need to do is have one page that will display whatever data is defined for that section. If the page has articles, links and images, that’s what it shows. If it has articles and links, that’s what it shows. If it just has articles, that’s what it shows.

This allows you to have one page, and to get the new content, all you need to do is publish it. If you want to work on your site, you could add a ‘published’ status to show only the content that is published. You could then allow a mode which shows unpublished content (basically a preview mode).

Off Topic:

Damn 500 Internal Server Error!!!

David,

Before I respond to your comments below, some background…

I started building v2.0 of my website back in the Summer of 2011. (Hey, I’m not a whiz like all of you SitePointers!!)

A few weeks ago, I had just finished testing v2.0. It looks and runs great, and I was planning on taking just a few days to put in live data, and then go live, when I came to this realization…

Over the last year or two, I have come up with TONS of new business ideas and Content. And, technically, while my website would handle most of this new Content, my original v2.0 design really needs to be “super-sized” to handle everything.

And so here I am… Frantically trying to tweak things so I don’t have to “down-size” all of the new Sections and Content I came up with, while also not having to completely re-code my website?! :eek:

Two big issues I have come across include:

Issue #1: Going from 5 Sections to maybe 40 Sections. While my code scales, there isn’t enough real-estate to accommodate things.

Good news is I have re-done my “Information Architecture”, and think that I have combined and whittled down those Sections to maybe 12 which seem to fit from a UI standpoint.

Issue #2: It had always been my plan to just release v2.0 with however many Sections, and each Section consisting of a “Listing of Articles” for said Section. (See screenshot above.)

With so much new Content (i.e. not just Articles), it occurred to me that I really should have a “Landing Page” for each Section.

So, if a user clicks on a Section, and after tha=ey end up on the “Landing Page”, if they still wanted to just read Articles, then they could be redirected to my “Listing of <Section> Articles” page and everything would work fine as far as Articles are concerned.

However, if they wanted to listen to a podcast, watch a video, view some statistics, and so on, then they could do that from the comfort of the “Section Landing Page”.

Seems simple enough, BUT, it may change things like: Directories, Apache mod_rewrites, and PHP substantially depending on what you advise me to do?!

Yes/No. (This may be Issue #3…)

I have a database designed to handle “Articles” for my website. And my current site is database-driven. However…

a.) I only have five “test” Articles, and so sometimes I lose perspective of how my site might look and work if I had say 100 or 1,000!

b.) I never got around to figuring out how to handle all of the OTHER CONTENT in my website… (Oops!!)

I guess I never planned out that far, but I just assumed my website content would consist of 85% Articles, and 15% static Reference (e.g. Laws by State, Sales Tax by State, Need-to-Know Gov’t Contact #'s, Statistics, etc.)

Since I have a decent templating system for my Articles, I was thinking of just changing how my URL and mod_rewrites work somewhat, and somehow utilizing my current code and tables used for Articles for things like mentioned above.

For example, I could type up a listing of “Important IRS Contact Tele #'s”, dump them into a new table similar to my Articles table, and use a modified template to display this info.

OR, at the same time, I could just create a static HTML page for now, since most of the 15% of the Content wouldn’t change.

Does that answer that question??

If so, all you need to do is have one page that will display whatever data is defined for that section. If the page has articles, links and images, that’s what it shows. If it has articles and links, that’s what it shows. If it just has articles, that’s what it shows.

Okay, but…

How do I structure that on the back end??

Approach #1: Create a directory for each Section, and place this “Section template” you are describing in said new directory. (It could be called “index.php” or whatever.)

Approach #2: Create one MONSTER template for all Sections, with complex logic that looks at the Query String to determine which code fires and how the “Section Landing Page” is built.

Cool idea, but too complicated, too late in the game.

Approach #3: Create a “section” directory, and in it keep a uniquely named “Section template” for each Section.

Then use my mod_rewrites to determine which template fires.

For example…


RewriteRule ^finance/$ section/index_finance.php [L]
RewriteRule ^legal/$ section/index_legal.php [L]
RewriteRule ^management/$ section/index_management.php [L]
RewriteRule ^small-business/$ section/index_small-business.php [L]

This way I could have completely different “Section Templates” for each Section - which will likely be the case - but have all of the templates reside in one new directory, and not muck up my Web Root with 15-20 new directories…

Approach #4: Maybe something else??

How does that sound?

Make sense?

Sincerely,

Debbie

This will be a repeat of my reply in the URL Rewriting forum, but since you already have a catch-all that is handled by a generic routing method, just use that.

Let your catch-all capture it, then in your routing code, add additional checks/constraints to handle sections the way you want. Thus no changes to your htaccess, you can then define new paths/includes to handle section landing pages for the sections you deem appropriate, etc.

Well, I think what you are calling my “catchall” is giving it too much credit…

Right now, I have a directory called “articles” and in it I have a template called “index.php”

All this file does is look at $_GET[‘section’] from the URL, and then call a simple SELECT query to populate the appropriate Article Summaries for the given Section. (This script has nothing to do with “Section Landing Pages” or all of the logic that would need to go in them!!)

I think that is a dangerous thing to get into all of that programmatically at this late stage…

What about Approach #3 above from my last post? (That seems like the easiest, and most scalable solution for this go-round…)

Sincerely,

Debbie

This is what you have right?

#Match any kind of Section.  PHP will decide if it's valid or not.
RewriteRule (.+)/$ articles/index.php?section=$1 [L]

If so, that is a fairly good catch all when it comes to sections, is it not?

So right now it directs all requests to articles/index.php?section=$1, you could change that to redirect to section.php?section=$1, then allow that page to read $_GET[‘section’] and determine where to send the request to articles/index.php?section=$1 (using include(‘articles/index.php’)) or someplace else (you’d want to do this using include() instead of header(‘Location: whatever’) as you don’t want to show the ugly url).

Correct.

If so, that is a fairly good catch all when it comes to sections, is it not?

Correct.

So right now it directs all requests to articles/index.php?section=$1, you could change that to redirect to section.php?section=$1, then allow that page to read $_GET[‘section’] and determine where to send the request to articles/index.php?section=$1 (using include(‘articles/index.php’)) or someplace else (you’d want to do this using include() instead of header(‘Location: whatever’) as you don’t want to show the ugly url).

You lost me here, and I’m not sure you’re following me.

Let me show you in pictures…

Here is my Home Page…

And if you clicked on the “Legal” navigation tab, this is what you would currently see…

(The logic works the same for any “Section” you choose in the Top Nav.)

This approach worked great when I had 5 Sections, and now that I am expanding to maybe 12-14 Section, it will still work, EXCEPT for a few catches…

1.) I will have a new “Other” tab that is a catchall, and will likely just have hyperlinks to other areas of my website.

So in that case, my articles/index.php is useless.

2.) In theory, most of these Sections should have more than just Articles. For instance, in the Small-Business area, I want to have an area where I can have either Podcasts or Videos of successful Small-Business Owners talking about how they got started. And in my “Finance” area, I may have Stock Quotes, or “USA Today”-esque summary charts on Small Business.

The point?

While for some Sections, just having a “Listing of Articles” may be okay, for most of these new Section, I will want a different layout which may still include a “Listing of Articles” (or may not), but will also include different content and hyperlinks.

Unfortunately, the only thing that articles/index.php knows how to do is serve up a listing of Articles.

Follow me?

3.) This isn’t as simple as just modifying articles/index.php, or renaming it as you imply.

As I see it - not really knowing the future - I will have slightly DIFFERENT “templates” for each Section.

Just think about your favorite newspaper, and in particular, how the print USA Today used to be in the early days… The layout for the “Money” section is vastly different than the “Sports” section, right?

Well, when all I had was just a “Listing of Articles”, I could use the same file/template for as many Sections as I wanted.

But moving forward, I will need a different template for each Section.

And as I said above, while it is possible to code one template, I think that is way too complex considering I could have 10 Section “Landing Pages” that each has a radically different layout?! :eek:

So I was originally leaning towards creating a separate directory for each Section, and having a separate template file called “index.php” in each new Section directory.

That way I could have one template be a 2-column layout, and another template be a 4-column layout, and another be whatever…

Of course the downside to that approach is mucking up my Web Root.

And the approach I came up with this afternoon, was creating a new directory called “section”, and then in that new directory, create a unique template file for each Section in my website. So, for example, it might have 15 templates.

Then I could use my mod_rewrite determine the Section the user chose - by looking in the URL - and then redirect to the appropriate template in this new “section” directory.

For example…


RewriteRule ^finance/$ section/index_finance.php [L]
RewriteRule ^legal/$ section/index_legal.php [L]
RewriteRule ^management/$ section/index_management.php [L]
RewriteRule ^small-business/$ section/index_small-business.php [L]

In a way, I would be doing what I am currently doing with my articles/index.php with the DIFFERENCE being that instead of always using the same template file and just passing something in the Query String to make the template look dofferent, my mod_rewrite would be determining WHICH TEMPLATE to use, which of course would then dictate not only the Content, but also the Layout of any given Section’s “Landing Page”.

Follow me??? (:

I am sure there many other approaches, and maybe some that are more sophisticated, but I personally like the approach I just mentioned, as it seems simple yet scalable.

Sincerely,

Debbie

12 should be doable from a usability perspective. Forty would definitely have been brain burnable…

We’l deal with issue two and 3B with the approaches below…

As for 3A, it sounds like you need to work out some sort of paging system. Say five articles per page. Maybe more, maybe less. You’d have to try it out based on your site layout and what you feel comfortable with…

Now onto the approaches and the remaining issues…

Personally, I think you’re over thinking it a bit as you’re “in the weeds” a bit. You need to look at it a little more abstractly. All you’re now talking about are different types of content. The approach should essentially be the same.

I’ll give you a quick pseudo-code example of what I mean…for any particular section:

  1. Are there articles for this section?
    [LIST=1]
  2. If yes, show X number of articles (may want to allow user to show by most recent, most popular, etc.)
    [/LIST]
  3. Are there videos for this section?
    [LIST=1]
  4. If yes, show x number of videos (see above re: sorting)
    [/LIST]
  5. Rinse and repeat with various types of content.

How you show them could be based on the number of different types. You could do

12 or 1
34 2
3

You could, but you’ll be kicking yourself later…

This is how I do it, and it’s NOT too complicated. You’ve already got it started with your article list page - use that as a baseline and expand on that.

Unless you’ve got a separate template for each section’s articles, you’ve already got most of the work done. If you’ve got a separate template for each section, you’ve got work ahead for you (which you didn’t need to do…)

re: #3 - Again, it’s a lot of work, especially if you’re still adding content (you’d have to handle each template as you add content - ugh). The more physical files you have, the harder it’ll be to maintain the site later.

:smiley:

As for 3A, it sounds like you need to work out some sort of paging system. Say five articles per page. Maybe more, maybe less. You’d have to try it out based on your site layout and what you feel comfortable with…

Yep, another thing I never planned for… :blush:

Now onto the approaches and the remaining issues…

Personally, I think you’re over thinking it a bit as you’re “in the weeds” a bit. You need to look at it a little more abstractly. All you’re now talking about are different types of content. The approach should essentially be the same.

I’ll give you a quick pseudo-code example of what I mean…for any particular section:

  1. Are there articles for this section?
    [LIST=1]
  2. If yes, show X number of articles (may want to allow user to show by most recent, most popular, etc.)
    [/LIST]
  3. Are there videos for this section?
    [LIST=1]
  4. If yes, show x number of videos (see above re: sorting)
    [/LIST]
  5. Rinse and repeat with various types of content.

How you show them could be based on the number of different types. You could do
12 or 1
34 2
3

I understand what you are saying, but it’s not quite that simple, because you are implying that what is shown is homogeneous.

If my page template never changed, but users could filter what content was show (e.g. Show All Articles, Show All Podcasts, Show All Videos), then, yes, the solution would be easy.

But I am anticipating having VASTLY DIFFERENT looking pages.

Here are some screen-shots from an online newspaper to make my point…

Home Page layout

Market Data layout

Radio layout

To just have ONE template that handle all of those different Page Layouts, and all of that different Content would be very complicated to program, although possible.

So in the example above, why not just have 3 separate page templates?

And back to my OP, I’m just wondering how to structure things on the backend.

Unless you’ve got a separate template for each section’s articles, you’ve already got most of the work done. If you’ve got a separate template for each section, you’ve got work ahead for you (which you didn’t need to do…)

Are you so sure about that based on the examples above??

re: #3 - Again, it’s a lot of work, especially if you’re still adding content (you’d have to handle each template as you add content - ugh). The more physical files you have, the harder it’ll be to maintain the site later.

Agreed, but a more robust website also requires more work…

Go look at http://www.bloomberg.com

I like the layout of that website, and I could see myself trying to emulate it.

Bloomberg has an entire IT Dept to make that website run?! So if I want anything close to that, I would expect it to take me more effort than a more “plain vanilla” approach, right?

[ot]I think a lot of my problem is that “I need ‘A’ to decide on ‘B’, and ‘B’ to decide on ‘A’…” That is, if I had already written 200 Articles, and I have 25 Podcasts, and maybe at least 10 Videos, and had created all of the other Content I want, THEN it would be easier to organize it!!

At the same time, if I don’t take time upfront to PLAN how I want things to be organized and laid out, THEN I may “paint myself into a corner” down the road with an inflexible architecture?!

Nice conundrum, eh?! (:

I think Bloomberg’s website looks really sharp and that is the kind of website I am striving towards. But obviously I have a long ways to go to get there.

Part of me is wondering if I shouldn’t just go live with v2.0 “as-is”, focus on writing a large body of Articles, start fleshing out each Section, and then after I have “real-world” Content to work with, I may have to go back and re-design part of my website.
[/ot]

So, I am still saying that I will need maybe 4-6 different Page Layout Templates for my 15 Sections… And back to my OP, I am just not sure what is the best way to go about that.

It seems like we agree that creating a directory for each Section isn’t very flexible, right?

However, you seem to say I can do all of this with One Template, whereas I am leaning towards “A Handful of Templates” (stored where and how I know not).

Looking forward to your reply…

Sincerely,

Debbie

Are you really going to have sections where you’ll have totally different content that will be on no other pages? If so, then by all means create separate templates.

The screenshots you attached are for two different purposes. The first one would most likely be more of what one of your sections would be. Go back to Bloomberg and look at Personal Finance, Technology News and Political News. Those are all identical - in fact, they are identical to the main landing page, just filtered by category/section.

The second and third screenshots are more content lists - they show podcasts and market data. But they are UNIQUE, where the rest is common.

So what you should be doing is looking to see if there is common ground between your sections, and use the same page if there is. Only create new pages if you have to. In fact, I would argue that you probably could use the home landing page as your default page, and just apply a section filter if appropriate. I’m betting that if you take a “thousand foot” view of your content, you probably will be able to look at most of your site through that home page view. Articles are articles, regardless of content. Same goes for links, images, etc. How they’re categorized doesn’t matter - it’s still all the same content types.

They are not “identical”, but I will agree that they are very similar.

The second and third screenshots are more content lists - they show podcasts and market data. But they are UNIQUE, where the rest is common.

I more or less agree.

So what you should be doing is looking to see if there is common ground between your sections, and use the same page if there is. Only create new pages if you have to.

I agree, and never implied I wouldn’t do that.

In fact, I would argue that you probably could use the home landing page as your default page, and just apply a section filter if appropriate.

In essence I already have that with my one Article Listing template…

But the whole idea of creating a “Landing Page” for each Section, is that I want a way to highlight DIFFERENT things in each Section. (That is, get away from making my website look like it is one page with a listing of Articles that can be filtered differently. Again, in most newspapers, the Local, Business, and Sports sections a wildly different in their page layouts, even if they all more or less contain “Articles” as the key content on the page.)

I’m betting that if you take a “thousand foot” view of your content, you probably will be able to look at most of your site through that home page view. Articles are articles, regardless of content. Same goes for links, images, etc. How they’re categorized doesn’t matter - it’s still all the same content types.

I don’t disagree.

Okay, but back to my larger question…

Let’s say that I agree with most of what you are saying above, but we also agree that I need 3-4 unique templates. 80% of my Sections would all fall under the “plain-vanilla Section template”, but then the other 3 templates are all vastly different.

That being said, how do I manage those as far as Directories, mod_rewrites, and PHP?

(You’ve never nibbled on my idea of having a new “section” directory which holds however many templates - in this case let’s say “4” - and then user my mod_rewrite to choose the appropriate template…)

Again, I WILL have more than one template, so how best to handle that?

Sincerely,

Debbie