4 ms·
In a somewhat similar situation I used PHP with `include`. The structure was something like this: - index.php - header.php - sidebar.php - footer.php
by roosgit 7y ago
In a somewhat similar situation I used PHP with `include`.
The structure was something like this:
- index.php
- header.php
- sidebar.php
- footer.php
- page-1.php
- page-2.php
...
In `header.php` I used variables for the title, description, etc. and then in each page I specified the values for those variables. This way each page had the same header HTML code, but with a different title, description and so on.
- Jaruzel 7y agoI do my PHP in completely different way, which in turn was the way I did ASP back in the day, also in a weird way. All my HTML is held in template .html files, with %%PLACEHOLDER%% text where the dynamic content should be, Then my index.php is the main 'app' loading in the templates to build the output, doing string replaces on the html, and then a single final 'echo' to send the result to the user at the end of the process. I think this is called 'code behind' - I've just always had a problem with mixing code and layout in the same file. Does anyone else do it like this?
- martin_a 7y agoYes, I've done it that way before. Actually just did a few weeks ago when building a frontend for a WordPress site. The frontend consumes the API and takes care of lightning-fast delivery by cutting out all the normal WordPress stuff that normally runs, when building a theme.
- benbristow 7y agoThat's nasty. Why not just use a templating language and pump in the values you need? https://twig.symfony.com/ https://twig.symfony.com/
- sethammons 7y agoHeh. That is what I was doing in 2001. Wild to it in the wild still. Now I am only in the back end.