1

I have a website that follows the following structure:

  • www.example.com/city1
  • www.example.com/city2
  • ...

Programmatically we change the logo which is hard-coded in a specific config file for city 1, city 2,... They are files in a folder structure like /cities/city1 or /cities/city2.

The colors can be changed by the admin of the city itself via the user interface, and it is saved in the database in a local_settings table where there's a column for bg_color.

However, I want to rework my entire system to white label the entire cities layout. But I was wondering how to go about this, I couldn't find much information googling this subject.

Should I:

  1. Keep on creating a config file for each city? And store each of the specific settings in there, where php reads and writes to the file?

  2. Save everything in the database? How do I structure this properly for scalability?

Extra question: imagine if a city wants its own footer on its sub-site, (which requires completely custom new HTML and CSS code), how do I go about this? Is it good practice to create a specific new footer.html file and put it in its specific /cities/ folder? And load it if it exists, otherwise load the general one?

1 Answer 1

6

Its been a few years now, but the last PHP system I developed did something like that. We offered custom domain names, rather than directories, but the principal is the same.

It was a template driven site. When a page was requested, it'd extract the domain name from the request. It would look that up in a db table, and obtain the metadata for that site (site id, name, title, company, etc) much like you are doing. For the templates, if we needed to load abc.template, it'd look first for 123/abc.template (if 123 was the site id), and use that if it existed, otherwise it would use the default abc.template.

The project ran successfully for over a decade and tracked billions of dollars in transactions. So, it worked well!

So I'd say you are on the right track.

3
  • Thanks for the reply! So you're saying to rather go for a database approach rather than a file based approach for storing stuff like color, logo, certain parameters,...?
    – Dennis
    Commented Sep 29, 2018 at 9:24
  • 2
    Its probably easiest to keep it in the db. But I don't think the decision is critical either way. A small include file w/ the site settings would work just as well. Commented Sep 30, 2018 at 2:22
  • 1
    This is what I do, although I use the "config file with default fallback values" approach. Why? Because the graphic designer guys/gals have access via (S)FTP, but not to the database, and we don't have enough apps or variations on them to justify writing a admin CRUD interface. For the potential scale y'all are discussing, database for sure!
    – ivanivan
    Commented Oct 13, 2018 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.